Production CT225 has uncommitted changes not in master:
- recentErrors.ts: add slimContext() to trim large context_data blobs
and expose context_data in the recent-errors response
- admin-ui resolve-by-pattern/route.ts: new endpoint
- admin-ui resolve-fixed-patterns/route.ts: new endpoint
This commit preserves the drift so it can be PR-reviewed and merged
over 7bc04e8 (PR20).
Paperclip-Issue: BIT-33338
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
The recent-errors handler (api/src/routes/public/recentErrors.ts) registers
both GET /api/error-monitoring/recent-errors and the alias
GET /v1/paperclip/recent-errors on the admin API (port 3200). However the
admin-ui Next.js rewrite sent all /v1/* to ingest-api (port 3041), which has
no such route, so the alias returned 404 in production while the
/api/error-monitoring path worked (401 without a key).
Changes:
- admin-ui/next.config.ts: add a specific /v1/paperclip/:path* -> admin API
rewrite before the generic /v1/:path* -> ingest-api rule (rewrite order
matters; first match wins).
- api/src/lib/errorMonitoringAuth.ts: authorizeReadQuery now also accepts an
X-Api-Key header carrying either ERROR_RESOLVE_API_KEY/ERROR_REPORTING_API_KEY
or DEBUG_VIEW_ERRORS_KEY, so programmatic callers avoid leaking keys in
URLs/access logs. Backward compatible with the existing query params.
- api/src/routes/public/recentErrors.test.ts: cover the alias path and the
X-Api-Key header (resolve key, view key, invalid key).
- docs/HTTP_CONTRACTS.md, docs/permission-matrix.md: document the header and
the proxy ordering requirement.
netvision's real error rate dropped sharply after the 2026-08-25..08-29 bug-fix
wave; at the global 168h threshold the weekly audit fired 3 weeks running for a
now-quiet app, not a broken pipe (BIT-30273/BIT-30527). Each investigation sent
a synthetic verification event to confirm the reporter still works, but those
events were then counted as "fresh" traffic by the next week's run, masking
the real last-event date until the synthetic row itself aged past the
threshold.
Add PAPERCLIP_FLEET_AUDIT_MAX_AGE_HOURS_OVERRIDES (CSV slug=hours) so a slug's
threshold can differ from the global default, and exclude events matching the
"[BIT-xxxxx] <actor> ... smoke test" marker convention from freshness scoring
so future liveness checks no longer pollute the metric.
Revert the BIT-25722 workaround now that BIT-30040 fixed the recent-errors
mega-incident query hang (verified <1s in prod with status=open,investigating,resolved,ignored&limit=2000).
BIT-29730's incident-first fast path still ran ROW_NUMBER() OVER
(PARTITION BY incident_id ...) across ALL occurrences of every
selected incident before filtering rn = 1. MariaDB can't turn a
PARTITION BY window function into a loose index scan, so it
materializes and sorts each partition in full. At fleet-audit scale
(status=open,investigating,resolved,ignored&limit=2000) several
"mega-incidents" with 48k-148k occurrences each landed in the
selected page, and sorting those partitions hung the query for 70s+.
Replace the ROW_NUMBER CTE with a `LIMIT 1` correlated subquery per
selected incident. EXPLAIN confirms this walks
er_incident_occurrences_incident_time_idx (incident_id, occurred_at
DESC) and stops at the first row per incident instead of scanning the
rest of its history.
Verified against MariaDB (docker compose) seeded with the production
shape from the bug report (3235 resolved / 20 open incidents, 5
mega-incidents at 48k-148k occurrences each, ~425k occurrence rows
total): status=open,investigating,resolved,ignored&limit=2000 dropped
from 2.1s to 0.44s with identical result rows, and
status=resolved&limit=10 stayed at ~0.3s untouched by the
mega-incidents.
recent-errors built its result by ranking ALL occurrences of every
matching incident with ROW_NUMBER() before applying LIMIT, so
status=resolved (the majority, longest-lived incident state) forced a
scan of the full historical occurrence log just to return one page.
admin/incidents.ts already filters/orders er_incidents directly for
this reason; apply the same pattern here: page through er_incidents
first (small, indexed by current_state), then rank occurrences only
for that page. The q= search path is kept on the old occurrence-first
query since it needs to match occurrence content across an incident's
full history.
Adds er_incidents_state_seen_idx (current_state, last_seen_at) so the
new incident-first path stays indexed even without a project_slug
filter, and backfills the docker/local migration runners that had
drifted behind deploy/lxc/run-migrate.sh (missing three prior
migrations), since the new migration needs to run through them too.
Verified locally against MariaDB (docker compose) with 3k resolved /
20 open incidents and ~90k synthetic occurrences: the reported repro
curls now return HTTP 200 in <100ms (previously reproduced as a hang
via manual EXPLAIN/timing of the old query, ~2s at this seed size and
scaling with total occurrence history).
switchSelectionEditorTab and descriptionEditorReady are absent from the
current codebase; continuing to suppress ReferenceErrors for these names
would silently hide real errors if the names were ever reused. Ruleset
bumped to 1.0.7.
Break down noise filter counters per noise policy rule for Prometheus observability.
Paperclip-Agent: David Santos (urlKey david-santos; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-26791
Paperclip-Run: cea24469-2886-457d-9f6f-09d83aaf9e4a
Add optional addedAt + expiresAfterDays to FixedPattern so each pattern
has a TTL. The resolve-fixed-patterns handler now skips expired patterns,
letting persistent errors resurface and forcing a real code fix instead
of indefinite suppression.
- Transient infra patterns (WSREP, Google API, session write) carry addedAt
for audit but no expiry — they are permanent noise with no code fix.
- fix-duplicate-logo.js expires 14 days after 2026-07-17; if still firing
after that the deploy or client filter is broken and needs attention.
- Response includes expired_pattern_count and per-pattern expired/expires_at.
- resolveFixedPatterns.ts: add '%fix-duplicate-logo.js%' entry so any
Chrome-style CRM JS error that reaches the hub is auto-resolved on deploy
- webhook-deploy.sh: call resolve-fixed-patterns after every service restart
so code fixes clear stale hub incidents automatically (uses ERROR_RESOLVE_API_KEY
from /etc/error-reporting/env which is already sourced by the script)
The 5 open incidents for ERRCLUSTER:33b4e527d8fd were bulk-resolved directly
(IDs 747145, 747381, 753209, 753550, 753551). Client-side noise filter (CRM PR #684)
prevents new occurrences.
- php-error bridge: accept paperclip_project_id / paperclipProjectId in
CrmPhpPayload and promote into event context alongside project_slug/gitea_repo
- recent-errors: extract paperclip_project_id from context_json and emit as
top-level field so error loop can route issues to the correct project board
column without falling back to PAPERCLIP_ERROR_LOOP_PROJECT_ID_BY_SLUG
- Add tests for include/omit behaviour (mirrors gitea_repo coverage)
- Update ERROR_MONITORING_PUBLIC_API.md to document both optional fields
No DB migration required: field is stored in existing context_json column.
Co-Authored-By: Paperclip <[email protected]>
Weekly routine that queries errors.bitreport.pt for each expected slug,
checks freshness against a configurable threshold, and creates Paperclip
correction issues for silent or stale reporters. Reads config from
/etc/paperclip/paperclip-fleet-error-audit.env.
Paperclip-Task-Id: BIT-25194
Co-Authored-By: Paperclip <[email protected]>
Next.js catches /api/* before Fastify, causing 404 on resolve-fixed-patterns.
Add rewrite so external callers (error-loop via CRM_RESOLVE_API_URL) reach
the hub Fastify API on port 3200 via the canonical errors.bitreport.pt URL.
Paperclip-Issue: BIT-25083
Co-Authored-By: Paperclip <[email protected]>
POST /api/error-monitoring/resolve-fixed-patterns — resolves hub incidents
matching known-fixed/transient patterns from config/resolveFixedPatterns.ts.
Fixes 404 from run-error-loop-with-resolve.sh when CRM_RESOLVE_API_URL points
to the hub (CRM module removed in BIT-24199; hub now owns all error monitoring).
Patterns file is extensible; initial set covers Galera/WSREP transients,
Google API backendError, session_write_close cascades, and storage COMMIT noise.
Paperclip-Issue: BIT-25072
Paperclip-Agent: tiago-neves
Block ingest for retired WDMI slugs, purge project data via migration,
remove WDMI runbooks, and add offboard-project helper for future retirements.
Co-authored-by: Cursor <[email protected]>
Join er_projects in ingest auth to expose lowercase project slug. Record
error_hub_last_event_timestamp from stored events occurred_at and
error_hub_ingest_failures_total on HTTP 500 batches (BIT-4903 / BIT-4932).
Add integration assertion when ERROR_REPORTING_TEST_DATABASE_URL is set.
Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-4932
Paperclip-Run: 00b93610-8794-4264-81a9-6f4cb39a9d8d
Made-with: Cursor
Pin matching versions in web/ and admin-ui/, document the decision and
Node requirement in README, and ignore TypeScript build info artefacts.
Made-with: Cursor
Align hub rate-limit error context with @fastify/rate-limit types, parse RATE_*
and body-size env vars via parsePositiveIntEnv, wire POST /admin/auth/login to
the login preset, increment er_api_rate_limit_rejections_total per bucket, and
document ingest_token_id plus Prometheus scraping notes.
Made-with: Cursor
Concurrent POSTs with the same Idempotency-Key could pass the initial
SELECT and collide on INSERT into er_ingest_idempotency (unique on
ingest_key_id + idempotency_key), surfacing ER_DUP_ENTRY and risking
duplicate occurrences. Acquire a per-key MySQL named lock before the
idempotency read; on duplicate insert, roll back and replay the stored
response. Document 503 idempotency_busy when GET_LOCK times out.
Adds an integration test for parallel identical idempotent requests (BIT-2530).
Made-with: Cursor
- api: Align rate-limit plugin docs with actual store (in-memory unless wired in
index); type errorResponseBuilder context; augment FastifyRequest with optional
ingest_token_id instead of casting to any.
- web: Upgrade to Next 15 / React 19; add ESLint 9 flat config, tsconfig,
next-env.d.ts; outputFileTracingRoot so file tracing stays within this product tree.
Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-2479
Paperclip-Run: e3292ca4-a7b9-42f1-83ca-bc3d78906532