Files
errors.bitreport.pt/docs/operations/ingest-hardening-runbook.md
T
Peter Spark 82f549adbc ingest: filter BIT-SMOKE- intentional probe events
Reserved BIT-SMOKE- messages (e.g. wdmi-store /smoke/wdmi.js direct-ingest
checks) are skipped at every ingest level so they do not open incidents or
trigger BIT-309 loops. Bump noise ruleset to 1.0.2; extend unit and integration
tests and ingest hardening runbook.

Paperclip-Issue: BIT-942
Made-with: Cursor
2026-04-05 05:23:32 +00:00

3.1 KiB

Ingest hardening — validation runbook (BIT-735)

Use this after deploying ingest API or changing fingerprint / noise / rate-limit behaviour.

Prerequisites

  • Apply DB migrations through 20260402140000_ingest_key_rate_limits so er_ingest_keys exposes rate_limit_max and rate_limit_window_ms.
  • Ingest keys are created in MariaDB (er_ingest_keys); clients send the raw token via Authorization: Bearer or X-Api-Key (never a shared WDMI env secret on the wire).

Environment

Variable Role
INGEST_RATE_LIMIT_MAX / INGEST_RATE_LIMIT_WINDOW_MS Default per-key budget when DB columns are NULL
INGEST_ANON_IP_MAX / INGEST_ANON_IP_WINDOW_MS Budget for POST /v1/ingest/events without credentials (abuse of 401 path)

Per-key overrides: set rate_limit_max and/or rate_limit_window_ms on the key row; NULL means inherit the corresponding env default.

Request schema (forward compatibility)

  • Top-level body must remain { "events": [ … ] } only (no extra root keys).
  • Each event object must include schema_version, occurred_at, level, and message. Additional event-level properties are accepted and ignored by the processor so integrators can attach metadata without breaking validation.

Fingerprint quality

  • Server-side fingerprint policy version is returned on each ingest response as fingerprint_policy_version.
  • When the client omits fingerprint, the hub hashes: normalized first line of message, context location (file_path / stack_info), project slug/name hints, and a digest of a normalized stacktrace (volatile tokens such as UUIDs and 0x… addresses collapsed).
  • Check: send the same logical error twice from different hosts; incident count should stay stable (one fingerprint) if stacktrace and context align.
  • Check: change only a UUID inside the stack; fingerprint should remain stable.

Noise filter coverage

  • Rules live in ingest-api/src/lib/noisePolicy.ts; ruleset id: noise_ruleset_version in the ingest response.
  • Check: send a known-noise payload (for example ResizeObserver message at non-fatal level); expect skipped: true, noise_filtered_count incremented, and no new er_incidents row.
  • Check: send the same pattern at fatal / critical level; expect not skipped (noise rules do not hide critical), except messages containing reserved substring BIT-SMOKE- (intentional reporter smoke, e.g. wdmi-store /smoke/wdmi.js) — those are skipped at every level (rule_id: bitreport_smoke_marker).

Rate limits

  • Authenticated traffic: 429 + Retry-After when the per-key window is exhausted (DB limits or env defaults).
  • Unauthenticated traffic: same for the client IP after INGEST_ANON_* budget.
  • Check: curl three rapid unauthenticated posts; third should be 429 if INGEST_ANON_IP_MAX=2.
  • Check: lower rate_limit_max on a test key to 2 and confirm the third authenticated request returns 429.

Automated tests

From ingest-api/:

npm test

Integration tests need ERROR_REPORTING_TEST_DATABASE_URL and an applied schema including rate-limit columns.