Files
errors.bitreport.pt/docs/operations/ingest-hardening-runbook.md
T
nelson-baptista b8ca70709e
CI / Test ingest-api (pull_request) Successful in 24s
CI / Test api (pull_request) Successful in 26s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m58s
CI / Validate Docker build (pull_request) Successful in 3m33s
fix(ingest): filter BIT-<id> smoke-test probes in noise policy (BIT-32681)
Hand-sent pipe-liveness probes referenced by a BIT task id (e.g.
`BIT-32663 smoke test` or `[BIT-30527] ... smoke test`) were not matched
by the ingest noise policy: they lack the reserved `BIT-SMOKE-` token and
the bracket-only fleet-audit regex, so they passed ingest and opened a
false-positive Error Loop issue (BIT-32681 / ERRCLUSTER a513bc4e4505).

- noisePolicy.ts: add `_BIT_ID_SMOKE_PROBE_RE` matching bare and bracketed
  `BIT-<id> ... smoke test` forms; filtered at every severity under the
  existing `bitreport_smoke_marker` rule. Bump ruleset 1.0.7 -> 1.0.8.
- noisePolicy.test.ts: cover bare, bracketed, critical-level, and a
  negative case (`Smoke detector sensor offline` stays unfiltered).
- paperclip_fleet_error_reporting_audit_once.py: relax `_SYNTHETIC_EVENT_RE`
  to the same bare/bracketed shape so ingest and fleet audit agree.
- docs/operations/ingest-hardening-runbook.md: document the new probe shape.

Verified locally: ingest-api vitest 44 passed | 14 skipped; typecheck clean;
reporter context contract ok; fleet audit py_compile ok.

Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8)
Paperclip-Issue: BIT-32681
Paperclip-Run: 64667793-6ac7-404b-80bc-f369f0c4f9e0
2026-11-20 09:42:08 +00:00

3.8 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 when the message or client-provided stacktrace contains reserved substring BIT-SMOKE- (intentional reporter smoke, e.g. wdmi-store /smoke/wdmi.js, CRM /smoke/crm-main.php, CRM /smoke/crm.php direct-forward BIT-SMOKE-CRM-DIRECT-FWD) — those are skipped at every level (rule_id: bitreport_smoke_marker). Matching treats unicode hyphen/minus characters as ASCII - (ruleset 1.0.5+). The exact deploy-probe failure ribbon BIT-SMOKE error hub ingest live check (space after BIT-SMOKE, see RUNBOOK_INGEST_DEBUG.md §0) is also skipped at every level with the same rule_id. Hand-sent pipe-liveness probes referenced by a BIT task id — BIT-<id> smoke test (bare) or [BIT-<id>] ... smoke test (bracketed) — are likewise skipped at every level (ruleset 1.0.8+, BIT-32681), aligning ingest with the fleet audit synthetic-event exclusion.

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.