Compare commits

...
Author SHA1 Message Date
tiago-neves 4bd1983645 Merge pull request 'fix(hub): preserve CT225 drift (context_data, resolve endpoints) + npm ci --include=dev (BIT-33336)' (#21) from task/BIT-33336-hotfix-drift-npm-ci into master
CI / Test ingest-api (push) Successful in 22s
CI / Test api (push) Successful in 23s
CI / Lint and typecheck admin-ui (push) Successful in 56s
CI / Validate Docker build (push) Successful in 3m26s
2026-11-25 12:29:28 +00:00
Tiago Neves 6a55df01bc fix(deploy): npm ci --include=dev in webhook-deploy.sh (BIT-33336)
CI / Test ingest-api (pull_request) Successful in 23s
CI / Test api (pull_request) Successful in 24s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m53s
CI / Validate Docker build (pull_request) Successful in 3m31s
Node 24/npm 11 omits devDependencies (tsc) on plain npm ci. Together with
the CT225 hotfix drift (context_data, resolve endpoints) preserved from
hotfix/ct225-drift-recent-errors.
2026-11-25 12:25:36 +00:00
Tiago Neves 40c646ab4b Merge remote-tracking branch 'origin/hotfix/ct225-drift-recent-errors' into task/BIT-33336-hotfix-drift-npm-ci 2026-11-25 12:25:17 +00:00
David Santos 3abd4ab804 hotfix(hub): preserve production drift — slimContext/context_data + resolve endpoints
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
2026-11-25 12:18:20 +00:00
spark 7bc04e8e1b Merge pull request 'feat(hub): populate event metadata columns + recent-errors fields (BIT-33316)' (#20) from task/BIT-33316-event-metadata into master
CI / Test ingest-api (push) Successful in 23s
CI / Test api (push) Successful in 26s
CI / Lint and typecheck admin-ui (push) Successful in 56s
CI / Validate Docker build (push) Successful in 3m31s
2026-11-25 05:54:44 +00:00
nelson-baptista 258f0b3cd4 fix(admin-ui): remove duplicate environment field in php-error payload type (BIT-33316)
CI / Test ingest-api (pull_request) Successful in 24s
CI / Test api (pull_request) Successful in 28s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m55s
CI / Validate Docker build (pull_request) Successful in 3m52s
Paperclip-Issue: BIT-33316
2026-11-25 05:45:28 +00:00
nelson-baptista b757ec671a feat(hub): populate runtime/host/release/request_id columns, honor environment, expose metadata in recent-errors (BIT-33316)
CI / Test ingest-api (pull_request) Successful in 22s
CI / Test api (pull_request) Successful in 25s
CI / Lint and typecheck admin-ui (pull_request) Failing after 2m12s
CI / Validate Docker build (pull_request) Failing after 3m15s
Paperclip-Issue: BIT-33316
2026-11-25 05:10:18 +00:00
spark baac48a632 Merge pull request 'fix(ingest): filter BIT-<id> smoke-test probes in noise policy (BIT-32681)' (#19) from fix/BIT-32681-smoke-probe-noise-filter into master
CI / Test ingest-api (push) Successful in 23s
CI / Test api (push) Successful in 24s
CI / Lint and typecheck admin-ui (push) Successful in 52s
CI / Validate Docker build (push) Successful in 3m23s
2026-11-20 10:03:24 +00:00
nelson-baptista b8ca70709e fix(ingest): filter BIT-<id> smoke-test probes in noise policy (BIT-32681)
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
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
spark e01c8f62d5 Merge pull request 'chore(runtime): BIT-31723 upgrade Node 20 → Node 24 LTS + audit PHP/TS code' (#18) from chore/BIT-31723-node24-upgrade into master
CI / Test ingest-api (push) Successful in 41s
CI / Test api (push) Successful in 37s
CI / Lint and typecheck admin-ui (push) Successful in 1m27s
CI / Validate Docker build (push) Successful in 5m23s
2026-10-23 17:38:00 +01:00
nelson-baptista 836d967aeb chore(runtime): BIT-31723 upgrade Node 20 → Node 24 LTS + audit PHP/TS code
CI / Test ingest-api (pull_request) Successful in 33s
CI / Test api (pull_request) Successful in 34s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m19s
CI / Validate Docker build (pull_request) Successful in 3m54s
- Dockerfiles (admin-ui, collector-worker, ingest-api): node:20-bookworm-slim → node:24-bookworm-slim
- CI (.gitea/workflows/ci.yml): node-version '20' → '24' in all 3 jobs
- package.json engines.node: '>=20' → '>=24.22.1' (admin-ui, api, collector-worker, ingest-api, web)
- @types/node: ^20/^22 → ^24 in all packages
- api: bcrypt ^5.1.1 → ^6.0.0 (Node 24 prebuilt binary compat)
- clients/php/ErrorReporter.php: PHP 8.4+ compat audit (no deprecated patterns)
- clients/node/errorReporter.mjs: Node 24+ doc update

All tests verified locally:
- api: 51/51 passed (vitest)
- ingest-api: 40 passed + 14 skipped (vitest)
- collector-worker: 12/12 passed (vitest)
- admin-ui: lint + typecheck clean
- web: lint + typecheck + build clean

Paperclip-Agent: Nelson Baptista (urlKey nelson-baptista; id e34f1b0f-62db-487c-8584-f6a47203f7b5)
Paperclip-Issue: BIT-31723
Paperclip-Run: 76d06689-1879-421f-ad2c-04f5fe85d21d
2026-10-23 17:30:13 +01:00
spark 73acc917f5 Merge pull request 'chore: fix CODEOWNERS to existing Gitea accounts' (#16) from chore/codeowners-fix into master
CI / Test ingest-api (push) Successful in 27s
CI / Test api (push) Successful in 27s
CI / Lint and typecheck admin-ui (push) Successful in 1m1s
CI / Validate Docker build (push) Successful in 3m50s
2026-10-22 04:57:12 +01:00
1sonhador 8f7ff6b1d5 chore: limit CODEOWNERS to active Gitea reviewers
CI / Test ingest-api (pull_request) Successful in 28s
CI / Test api (pull_request) Successful in 34s
CI / Lint and typecheck admin-ui (pull_request) Successful in 59s
CI / Validate Docker build (pull_request) Successful in 4m16s
Only owners that review in practice are listed, so official review
requests from code owners never block merges on protected branches.
2026-10-22 04:45:10 +01:00
spark dc1aa3365e Merge branch 'master' into chore/codeowners-fix
CI / Test ingest-api (pull_request) Successful in 36s
CI / Test api (pull_request) Successful in 36s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m3s
CI / Validate Docker build (pull_request) Successful in 3m2s
2026-10-22 01:16:24 +01:00
spark d987d2aaf4 Merge pull request 'fix(hub): BIT-31442 route /v1/paperclip alias to admin API + accept X-Api-Key header' (#17) from fix/BIT-31442-recent-errors-alias-proxy-and-xapikey into master
CI / Test ingest-api (push) Successful in 25s
CI / Test api (push) Successful in 29s
CI / Lint and typecheck admin-ui (push) Successful in 59s
CI / Validate Docker build (push) Successful in 4m24s
2026-10-21 20:40:24 +01:00
David Santos d4059d801a fix(hub): BIT-31442 route /v1/paperclip alias to admin API + accept X-Api-Key header
CI / Test ingest-api (pull_request) Successful in 41s
CI / Test api (pull_request) Successful in 44s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m24s
CI / Validate Docker build (pull_request) Successful in 6m2s
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.
2026-10-21 18:16:05 +01:00
1sonhador 9e318b5b9a chore: corrige CODEOWNERS para contas existentes no Gitea
CI / Test ingest-api (pull_request) Successful in 2m12s
CI / Test api (pull_request) Successful in 2m2s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m37s
CI / Validate Docker build (pull_request) Successful in 4m59s
2026-10-21 17:33:02 +01:00
spark 954b0ced2e Merge pull request 'chore(hub): BIT-30701 add per-slug freshness override + exclude synthetic smoke-test events from fleet audit' (#15) from chore/BIT-30701-fleet-audit-per-slug-threshold-and-synthetic-filter into master
CI / Test ingest-api (push) Successful in 1m2s
CI / Test api (push) Successful in 1m11s
CI / Lint and typecheck admin-ui (push) Successful in 2m6s
CI / Validate Docker build (push) Successful in 5m11s
2026-09-28 08:22:42 +01:00
David Santos 9dd88db4ae chore(hub): BIT-30701 add per-slug freshness override + exclude synthetic smoke-test events from fleet audit
CI / Test ingest-api (pull_request) Successful in 55s
CI / Test api (pull_request) Successful in 1m1s
CI / Lint and typecheck admin-ui (pull_request) Successful in 2m9s
CI / Validate Docker build (pull_request) Successful in 5m55s
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.
2026-09-28 08:22:16 +01:00
spark 52e75a8760 Merge pull request 'chore(hub): BIT-30044 restore multi-status filter in fleet audit script' (#14) from chore/BIT-30044-restore-multistatus-audit-filter into master
CI / Test ingest-api (push) Successful in 1m28s
CI / Test api (push) Successful in 1m30s
CI / Lint and typecheck admin-ui (push) Successful in 2m42s
CI / Validate Docker build (push) Successful in 6m25s
2026-09-07 09:40:05 +01:00
David Santos b190d6fa1b chore(hub): BIT-30044 restore multi-status filter in fleet audit script
CI / Test ingest-api (pull_request) Successful in 54s
CI / Test api (pull_request) Successful in 1m6s
CI / Lint and typecheck admin-ui (pull_request) Successful in 2m37s
CI / Validate Docker build (pull_request) Successful in 6m56s
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).
2026-09-07 09:39:28 +01:00
spark 3da9e47873 Merge pull request 'fix(hub): BIT-30040 stop ROW_NUMBER from materializing mega-incident partitions' (#13) from fix/BIT-30040-recent-errors-mega-incident-fastpath into master
CI / Test ingest-api (push) Successful in 1m26s
CI / Test api (push) Successful in 1m41s
CI / Lint and typecheck admin-ui (push) Successful in 3m28s
CI / Validate Docker build (push) Successful in 7m8s
2026-09-07 09:12:28 +01:00
David Santos a1fd3d2db0 fix(hub): BIT-30040 stop ROW_NUMBER from materializing mega-incident partitions
CI / Test ingest-api (pull_request) Successful in 1m9s
CI / Test api (pull_request) Successful in 1m22s
CI / Lint and typecheck admin-ui (pull_request) Successful in 2m30s
CI / Validate Docker build (pull_request) Successful in 8m52s
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.
2026-09-07 09:05:52 +01:00
spark 7f76c5287d Merge pull request 'fix(hub): BIT-29730 stop timeout on GET recent-errors?status=resolved' (#12) from fix/BIT-29730-recent-errors-resolved-timeout into master
CI / Test ingest-api (push) Successful in 49s
CI / Test api (push) Successful in 50s
CI / Lint and typecheck admin-ui (push) Successful in 1m29s
CI / Validate Docker build (push) Successful in 4m27s
2026-08-24 09:02:38 +01:00
David Santos 7987aa94ae fix(hub): BIT-29730 stop timeout on GET recent-errors?status=resolved
CI / Test ingest-api (pull_request) Successful in 1m13s
CI / Test api (pull_request) Successful in 1m12s
CI / Lint and typecheck admin-ui (pull_request) Successful in 1m45s
CI / Validate Docker build (pull_request) Successful in 5m11s
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).
2026-08-24 08:32:26 +01:00
David Santos 308ff624cf fix(noise): remove stale_bundle_* rules — functions no longer exist (BIT-26793)
CI / Test ingest-api (push) Successful in 54s
CI / Test api (push) Successful in 58s
CI / Lint and typecheck admin-ui (push) Successful in 1m29s
CI / Validate Docker build (push) Successful in 5m0s
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.
2026-07-17 23:02:36 +00:00
David Santos 23704d2e59 feat(ingest): label er_ingest_events_total skipped_noise by rule_id
CI / Test api (push) Successful in 54s
CI / Test ingest-api (push) Successful in 57s
CI / Lint and typecheck admin-ui (push) Successful in 1m48s
CI / Validate Docker build (push) Successful in 5m19s
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
2026-07-17 23:01:35 +00:00
David Santos caeb37ff0a feat(hub): time-limited fixed patterns — expire after N days (BIT-26790)
CI / Test ingest-api (push) Successful in 48s
CI / Test api (push) Successful in 47s
CI / Lint and typecheck admin-ui (push) Successful in 1m20s
CI / Validate Docker build (push) Successful in 4m29s
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.
2026-07-17 22:42:56 +00:00
David Santos 37ab9f1ccb fix(hub): BIT-25223 add fix-duplicate-logo.js resolve pattern + auto-apply on deploy
CI / Test api (push) Successful in 1m8s
CI / Test ingest-api (push) Successful in 1m9s
CI / Lint and typecheck admin-ui (push) Successful in 1m30s
CI / Validate Docker build (push) Successful in 5m22s
- 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.
2026-07-17 22:20:18 +00:00
David Santos 615d771ade fix(tools): drop multi-status filter in fleet audit — hub times out on comma-separated status values
CI / Test ingest-api (push) Failing after 40s
CI / Lint and typecheck admin-ui (push) Failing after 43s
CI / Validate Docker build (push) Failing after 42s
CI / Test api (push) Failing after 10m49s
Paperclip-Task-Id: BIT-25722
2026-06-22 07:22:16 +00:00
David SantosandPaperclip 3c307ea32d feat(hub): accept and expose paperclip_project_id on error records (BIT-25537)
- 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]>
2026-06-18 02:15:49 +00:00
David SantosandPaperclip be735a16b6 feat(tools): add fleet error reporting audit script (BIT-25194)
CI / Test ingest-api (push) Successful in 2m18s
CI / Test api (push) Successful in 2m24s
CI / Lint and typecheck admin-ui (push) Successful in 3m14s
CI / Validate Docker build (push) Successful in 12m14s
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]>
2026-06-15 07:21:16 +00:00
tiago-nevesandPaperclip 050a380230 fix(admin-ui): proxy /api/error-monitoring/* to Fastify API (BIT-25083)
CI / Test ingest-api (push) Successful in 1m51s
CI / Test api (push) Successful in 1m50s
CI / Lint and typecheck admin-ui (push) Successful in 2m15s
CI / Validate Docker build (push) Successful in 7m29s
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]>
2026-06-14 02:23:41 +00:00
spark bebbfb3e57 Merge pull request 'feat(hub): add resolve-fixed-patterns endpoint for CRM routing parity (BIT-25072)' (#11) from task/BIT-25072-resolve-fixed-patterns into master
CI / Test ingest-api (push) Successful in 2m52s
CI / Test api (push) Successful in 2m53s
CI / Lint and typecheck admin-ui (push) Successful in 3m14s
CI / Validate Docker build (push) Successful in 12m41s
feat(hub): add resolve-fixed-patterns endpoint for CRM routing parity (BIT-25072)
2026-06-14 02:04:22 +01:00
48 changed files with 1304 additions and 716 deletions

No files matched your search

+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain. # Replace/add owners as needed per repository domain.
# CI and forge metadata # CI and forge metadata
/.gitea/ @tiago-neves @david-santos /.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @tiago-neves @david-santos /.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation # Documentation
/docs/ @david-santos @planner /docs/ @founding-engineer
# Catch-all # Catch-all
* @david-santos * @founding-engineer
+3 -3
View File
@@ -18,7 +18,7 @@ jobs:
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '24'
cache: 'npm' cache: 'npm'
cache-dependency-path: 'ingest-api/package-lock.json' cache-dependency-path: 'ingest-api/package-lock.json'
@@ -39,7 +39,7 @@ jobs:
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '24'
cache: 'npm' cache: 'npm'
cache-dependency-path: 'api/package-lock.json' cache-dependency-path: 'api/package-lock.json'
@@ -60,7 +60,7 @@ jobs:
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '24'
cache: 'npm' cache: 'npm'
cache-dependency-path: 'admin-ui/package-lock.json' cache-dependency-path: 'admin-ui/package-lock.json'
+3 -3
View File
@@ -1,17 +1,17 @@
# Next.js 15 admin UI (Velzon-style) — production image for docker-compose. # Next.js 15 admin UI (Velzon-style) — production image for docker-compose.
FROM node:20-bookworm-slim AS deps FROM node:24-bookworm-slim AS deps
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
FROM node:20-bookworm-slim AS build FROM node:24-bookworm-slim AS build
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build RUN npm run build
FROM node:20-bookworm-slim AS runner FROM node:24-bookworm-slim AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
@@ -35,6 +35,17 @@ interface CrmPhpPayload {
project_slug?: unknown; project_slug?: unknown;
project_name?: unknown; project_name?: unknown;
gitea_repo?: unknown; gitea_repo?: unknown;
// Paperclip project UUID — used by error loop to route issues to the correct project board column
paperclip_project_id?: unknown;
paperclipProjectId?: unknown;
// telemetry metadata (BIT-33316) — canonical keys + legacy aliases
component?: unknown;
release?: unknown;
release_version?: unknown;
runtime_name?: unknown;
runtime_version?: unknown;
host_name?: unknown;
hostname?: unknown;
} }
function safeStr(v: unknown): string { function safeStr(v: unknown): string {
@@ -94,9 +105,23 @@ export async function POST(request: NextRequest) {
const gitea_repo = safeStr(body.gitea_repo); const gitea_repo = safeStr(body.gitea_repo);
const project_slug = safeStr(body.project_slug); const project_slug = safeStr(body.project_slug);
const project_name = safeStr(body.project_name); const project_name = safeStr(body.project_name);
const paperclip_project_id = safeStr(body.paperclip_project_id || body.paperclipProjectId);
if (gitea_repo) contextData.gitea_repo = gitea_repo; if (gitea_repo) contextData.gitea_repo = gitea_repo;
if (project_slug) contextData.project_slug = project_slug; if (project_slug) contextData.project_slug = project_slug;
if (project_name) contextData.project_name = project_name; if (project_name) contextData.project_name = project_name;
if (paperclip_project_id) contextData.paperclip_project_id = paperclip_project_id;
const metaPairs: Array<[string, string]> = [
["component", safeStr(body.component)],
["release_version", safeStr(body.release_version || body.release)],
["runtime_name", safeStr(body.runtime_name)],
["runtime_version", safeStr(body.runtime_version)],
["host_name", safeStr(body.host_name || body.hostname)],
["environment", safeStr(body.environment)],
];
for (const [k, v] of metaPairs) {
if (v) contextData[k] = v;
}
// Preserve other top-level diagnostic fields. // Preserve other top-level diagnostic fields.
const file_path = safeStr(body.file_path); const file_path = safeStr(body.file_path);
@@ -0,0 +1,47 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function POST(request: NextRequest) {
const rawBase = process.env.ERROR_REPORTING_ADMIN_API_BASE?.trim();
if (!rawBase) {
return NextResponse.json(
{
success: false,
message: "ERROR_REPORTING_ADMIN_API_BASE is not configured.",
},
{ status: 503 },
);
}
const base = rawBase.replace(/\/$/, "");
const target = `${base}/api/error-monitoring/resolve-by-pattern`;
const body = await request.text();
const headers: Record<string, string> = {
Accept: "application/json",
"Content-Type": request.headers.get("Content-Type") ?? "application/json",
};
const cookie = request.headers.get("cookie");
if (cookie) {
headers.Cookie = cookie;
}
const resolveHdr = request.headers.get("x-error-resolve-key");
if (resolveHdr) {
headers["X-Error-Resolve-Key"] = resolveHdr;
}
const upstream = await fetch(target, {
method: "POST",
headers,
body: body || undefined,
cache: "no-store",
});
const text = await upstream.text();
const ct = upstream.headers.get("Content-Type") ?? "application/json; charset=utf-8";
return new NextResponse(text, {
status: upstream.status,
headers: { "Content-Type": ct },
});
}
@@ -0,0 +1,47 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function POST(request: NextRequest) {
const rawBase = process.env.ERROR_REPORTING_ADMIN_API_BASE?.trim();
if (!rawBase) {
return NextResponse.json(
{
success: false,
message: "ERROR_REPORTING_ADMIN_API_BASE is not configured.",
},
{ status: 503 },
);
}
const base = rawBase.replace(/\/$/, "");
const target = `${base}/api/error-monitoring/resolve-fixed-patterns`;
const body = await request.text();
const headers: Record<string, string> = {
Accept: "application/json",
"Content-Type": request.headers.get("Content-Type") ?? "application/json",
};
const cookie = request.headers.get("cookie");
if (cookie) {
headers.Cookie = cookie;
}
const resolveHdr = request.headers.get("x-error-resolve-key");
if (resolveHdr) {
headers["X-Error-Resolve-Key"] = resolveHdr;
}
const upstream = await fetch(target, {
method: "POST",
headers,
body: body || undefined,
cache: "no-store",
});
const text = await upstream.text();
const ct = upstream.headers.get("Content-Type") ?? "application/json; charset=utf-8";
return new NextResponse(text, {
status: upstream.status,
headers: { "Content-Type": ct },
});
}
+22
View File
@@ -7,6 +7,15 @@ import type { NextConfig } from "next";
const INGEST_API_URL = const INGEST_API_URL =
process.env.INGEST_API_URL || "http://127.0.0.1:3041"; process.env.INGEST_API_URL || "http://127.0.0.1:3041";
/**
* Admin/mutation API backend (same LXC, port 3200).
* Proxies hub-only mutation endpoints (resolve-fixed-patterns, etc.) so they are
* reachable via the public errors.bitreport.pt hostname without a separate FQDN.
* BIT-25072: resolve-fixed-patterns is hub-only; CRM error-loop calls this via HTTPS.
*/
const ADMIN_API_URL =
process.env.ERROR_REPORTING_ADMIN_API_BASE || "http://127.0.0.1:3200";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
reactStrictMode: true, reactStrictMode: true,
@@ -14,7 +23,20 @@ const nextConfig: NextConfig = {
async rewrites() { async rewrites() {
return [ return [
{ source: "/health", destination: `${INGEST_API_URL}/health` }, { source: "/health", destination: `${INGEST_API_URL}/health` },
// BIT-31442: the recent-errors handler (api/src/routes/public/recentErrors.ts)
// registers the /v1/paperclip/recent-errors alias on the admin API (port 3200),
// not on ingest-api. The generic /v1/* rule below would otherwise send it to
// ingest-api (port 3041), which has no such route and returns 404. This more
// specific rule must come first; Next.js evaluates rewrites in order.
{
source: "/v1/paperclip/:path*",
destination: `${ADMIN_API_URL}/v1/paperclip/:path*`,
},
{ source: "/v1/:path*", destination: `${INGEST_API_URL}/v1/:path*` }, { source: "/v1/:path*", destination: `${INGEST_API_URL}/v1/:path*` },
{
source: "/api/error-monitoring/:path*",
destination: `${ADMIN_API_URL}/api/error-monitoring/:path*`,
},
]; ];
}, },
}; };
+11 -27
View File
@@ -15,7 +15,7 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.2.0", "@eslint/eslintrc": "^3.2.0",
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"@types/react": "19.2.14", "@types/react": "19.2.14",
"@types/react-dom": "19.2.3", "@types/react-dom": "19.2.3",
"eslint": "^9.15.0", "eslint": "^9.15.0",
@@ -24,7 +24,7 @@
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
}, },
"node_modules/@emnapi/core": { "node_modules/@emnapi/core": {
@@ -931,7 +931,6 @@
"version": "2.5.6", "version": "2.5.6",
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz",
"integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==", "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==",
"dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
@@ -971,7 +970,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -992,7 +990,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1013,7 +1010,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1034,7 +1030,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1055,7 +1050,6 @@
"cpu": [ "cpu": [
"arm" "arm"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1076,7 +1070,6 @@
"cpu": [ "cpu": [
"arm" "arm"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1097,7 +1090,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1118,7 +1110,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1139,7 +1130,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1160,7 +1150,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1181,7 +1170,6 @@
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1202,7 +1190,6 @@
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1223,7 +1210,6 @@
"cpu": [ "cpu": [
"x64" "x64"
], ],
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"os": [ "os": [
@@ -1241,7 +1227,6 @@
"version": "4.0.3", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true, "optional": true,
"engines": { "engines": {
@@ -1318,13 +1303,13 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.19.15", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.15.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
"integrity": "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==", "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": ">=7.24.0 <7.24.7"
} }
}, },
"node_modules/@types/react": { "node_modules/@types/react": {
@@ -3811,7 +3796,7 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@@ -3857,7 +3842,7 @@
"version": "4.0.3", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"is-extglob": "^2.1.1" "is-extglob": "^2.1.1"
@@ -4407,7 +4392,6 @@
"version": "7.1.1", "version": "7.1.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
"dev": true,
"license": "MIT", "license": "MIT",
"optional": true "optional": true
}, },
@@ -5664,9 +5648,9 @@
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.21.0", "version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
+2 -2
View File
@@ -18,7 +18,7 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.2.0", "@eslint/eslintrc": "^3.2.0",
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"@types/react": "19.2.14", "@types/react": "19.2.14",
"@types/react-dom": "19.2.3", "@types/react-dom": "19.2.3",
"eslint": "^9.15.0", "eslint": "^9.15.0",
@@ -27,6 +27,6 @@
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
} }
+4
View File
@@ -55,6 +55,10 @@ Each row includes CRM-compatible fields. For non-resolved incidents, `status` is
**`stack_trace`:** Non-empty for every row: missing client stacks are synthesized on ingest; legacy DB rows with null/blank `stack_trace` get the same synthesis when serializing this endpoint (BIT-1008). **`stack_trace`:** Non-empty for every row: missing client stacks are synthesized on ingest; legacy DB rows with null/blank `stack_trace` get the same synthesis when serializing this endpoint (BIT-1008).
**`gitea_repo`** *(optional)*: Gitea `Owner/Repo` path (e.g. `BitReport.pt/WDMI`) if the reporter sent `gitea_repo` in the error payload. Omitted when not present.
**`paperclip_project_id`** *(optional)*: Paperclip project UUID sent by the reporter (via `paperclip_project_id` or `paperclipProjectId` payload field). When present, the Paperclip error loop uses this UUID directly to route issues to the correct project board column instead of falling back to the `PAPERCLIP_ERROR_LOOP_PROJECT_ID_BY_SLUG` env map. Omitted when not present.
**Example** **Example**
```bash ```bash
+30 -585
View File
@@ -14,7 +14,7 @@
"@fastify/rate-limit": "^9.1.0", "@fastify/rate-limit": "^9.1.0",
"@fastify/swagger": "^8.14.0", "@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^3.0.0", "@fastify/swagger-ui": "^3.0.0",
"bcrypt": "^5.1.1", "bcrypt": "^6.0.0",
"fastify": "^4.28.1", "fastify": "^4.28.1",
"mysql2": "^3.11.5", "mysql2": "^3.11.5",
"pino": "^9.1.0", "pino": "^9.1.0",
@@ -23,10 +23,13 @@
}, },
"devDependencies": { "devDependencies": {
"@types/bcrypt": "^5.0.2", "@types/bcrypt": "^5.0.2",
"@types/node": "^20.14.0", "@types/node": "^24.0.0",
"tsx": "^4.15.6", "tsx": "^4.15.6",
"typescript": "^5.4.5", "typescript": "^5.4.5",
"vitest": "^1.6.0" "vitest": "^1.6.0"
},
"engines": {
"node": ">=24.22.1"
} }
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
@@ -658,26 +661,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/@mapbox/node-pre-gyp": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz",
"integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==",
"license": "BSD-3-Clause",
"dependencies": {
"detect-libc": "^2.0.0",
"https-proxy-agent": "^5.0.0",
"make-dir": "^3.1.0",
"node-fetch": "^2.6.7",
"nopt": "^5.0.0",
"npmlog": "^5.0.1",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"tar": "^6.1.11"
},
"bin": {
"node-pre-gyp": "bin/node-pre-gyp"
}
},
"node_modules/@opentelemetry/api": { "node_modules/@opentelemetry/api": {
"version": "1.9.1", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz",
@@ -1078,12 +1061,12 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.19.37", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.37.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
"integrity": "sha512-8kzdPJ3FsNsVIurqBs7oodNnCEVbni9yUEkaHbgptDACOPW04jimGagZ51E6+lXUwJjgnBw+hyko/lkFWCldqw==", "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": ">=7.24.0 <7.24.7"
} }
}, },
"node_modules/@vitest/expect": { "node_modules/@vitest/expect": {
@@ -1160,12 +1143,6 @@
"url": "https://opencollective.com/vitest" "url": "https://opencollective.com/vitest"
} }
}, },
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"license": "ISC"
},
"node_modules/abstract-logging": { "node_modules/abstract-logging": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz", "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz",
@@ -1198,18 +1175,6 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"license": "MIT",
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/ajv": { "node_modules/ajv": {
"version": "8.18.0", "version": "8.18.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",
@@ -1284,26 +1249,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/aproba": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-2.1.0.tgz",
"integrity": "sha512-tLIEcj5GuR2RSTnxNKdkK0dJ/GrC7P38sUkiDmDuHfsHmbagTFAxDVIBltoklXEVIQ/f14IL8IMJ5pn9Hez1Ew==",
"license": "ISC"
},
"node_modules/are-we-there-yet": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz",
"integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==",
"deprecated": "This package is no longer supported.",
"license": "ISC",
"dependencies": {
"delegates": "^1.0.0",
"readable-stream": "^3.6.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/asn1.js": { "node_modules/asn1.js": {
"version": "5.4.1", "version": "5.4.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
@@ -1361,17 +1306,17 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/bcrypt": { "node_modules/bcrypt": {
"version": "5.1.1", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-6.0.0.tgz",
"integrity": "sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==", "integrity": "sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg==",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11", "node-addon-api": "^8.3.0",
"node-addon-api": "^5.0.0" "node-gyp-build": "^4.8.4"
}, },
"engines": { "engines": {
"node": ">= 10.0.0" "node": ">= 18"
} }
}, },
"node_modules/bintrees": { "node_modules/bintrees": {
@@ -1437,15 +1382,6 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/chownr": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==",
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/color-convert": { "node_modules/color-convert": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
@@ -1464,21 +1400,6 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/color-support": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
"license": "ISC",
"bin": {
"color-support": "bin.js"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"license": "MIT"
},
"node_modules/confbox": { "node_modules/confbox": {
"version": "0.1.8", "version": "0.1.8",
"resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz",
@@ -1486,12 +1407,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==",
"license": "ISC"
},
"node_modules/content-disposition": { "node_modules/content-disposition": {
"version": "0.5.4", "version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
@@ -1566,12 +1481,6 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/delegates": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
"integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==",
"license": "MIT"
},
"node_modules/denque": { "node_modules/denque": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
@@ -1590,15 +1499,6 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/detect-libc": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
"license": "Apache-2.0",
"engines": {
"node": ">=8"
}
},
"node_modules/diff-sequences": { "node_modules/diff-sequences": {
"version": "29.6.3", "version": "29.6.3",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz",
@@ -1912,36 +1812,6 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/fs-minipass": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
"integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==",
"license": "ISC",
"dependencies": {
"minipass": "^3.0.0"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/fs-minipass/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"license": "ISC",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"license": "ISC"
},
"node_modules/fsevents": { "node_modules/fsevents": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -1957,74 +1827,6 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0" "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
} }
}, },
"node_modules/gauge": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz",
"integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==",
"deprecated": "This package is no longer supported.",
"license": "ISC",
"dependencies": {
"aproba": "^1.0.3 || ^2.0.0",
"color-support": "^1.1.2",
"console-control-strings": "^1.0.0",
"has-unicode": "^2.0.1",
"object-assign": "^4.1.1",
"signal-exit": "^3.0.0",
"string-width": "^4.2.3",
"strip-ansi": "^6.0.1",
"wide-align": "^1.1.2"
},
"engines": {
"node": ">=10"
}
},
"node_modules/gauge/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/gauge/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/gauge/node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
"license": "ISC"
},
"node_modules/gauge/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/gauge/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/generate-function": { "node_modules/generate-function": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
@@ -2091,12 +1893,6 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/has-unicode": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==",
"license": "ISC"
},
"node_modules/helmet": { "node_modules/helmet": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-7.2.0.tgz", "resolved": "https://registry.npmjs.org/helmet/-/helmet-7.2.0.tgz",
@@ -2122,19 +1918,6 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/https-proxy-agent": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
"license": "MIT",
"dependencies": {
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/human-signals": { "node_modules/human-signals": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz",
@@ -2161,17 +1944,6 @@
"url": "https://opencollective.com/express" "url": "https://opencollective.com/express"
} }
}, },
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
"license": "ISC",
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": { "node_modules/inherits": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -2350,30 +2122,6 @@
"@jridgewell/sourcemap-codec": "^1.5.5" "@jridgewell/sourcemap-codec": "^1.5.5"
} }
}, },
"node_modules/make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
"integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==",
"license": "MIT",
"dependencies": {
"semver": "^6.0.0"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/make-dir/node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/merge-stream": { "node_modules/merge-stream": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -2436,43 +2184,6 @@
"node": ">=16 || 14 >=14.17" "node": ">=16 || 14 >=14.17"
} }
}, },
"node_modules/minizlib": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz",
"integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==",
"license": "MIT",
"dependencies": {
"minipass": "^3.0.0",
"yallist": "^4.0.0"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/minizlib/node_modules/minipass": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
"integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
"license": "ISC",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"license": "MIT",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mlly": { "node_modules/mlly": {
"version": "1.8.2", "version": "1.8.2",
"resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.2.tgz", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.2.tgz",
@@ -2562,44 +2273,23 @@
} }
}, },
"node_modules/node-addon-api": { "node_modules/node-addon-api": {
"version": "5.1.0", "version": "8.9.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.2.tgz",
"integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==", "integrity": "sha512-VijLXbi3UACN69I0JVXJsX4tjACjNoQDgv2gTF6sx2wWEi8tkSg2eX8p5gSIFi8z2+DL3oHmY6OyKce38SDolg==",
"license": "MIT"
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT", "license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": { "engines": {
"node": "4.x || >=6.0.0" "node": "^18 || ^20 || >= 21"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
} }
}, },
"node_modules/nopt": { "node_modules/node-gyp-build": {
"version": "5.0.0", "version": "4.8.4",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
"integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
"license": "ISC", "license": "MIT",
"dependencies": {
"abbrev": "1"
},
"bin": { "bin": {
"nopt": "bin/nopt.js" "node-gyp-build": "bin.js",
}, "node-gyp-build-optional": "optional.js",
"engines": { "node-gyp-build-test": "build-test.js"
"node": ">=6"
} }
}, },
"node_modules/npm-run-path": { "node_modules/npm-run-path": {
@@ -2631,28 +2321,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/npmlog": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz",
"integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==",
"deprecated": "This package is no longer supported.",
"license": "ISC",
"dependencies": {
"are-we-there-yet": "^2.0.0",
"console-control-strings": "^1.1.0",
"gauge": "^3.0.0",
"set-blocking": "^2.0.0"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/obliterator": { "node_modules/obliterator": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/obliterator/-/obliterator-2.0.5.tgz", "resolved": "https://registry.npmjs.org/obliterator/-/obliterator-2.0.5.tgz",
@@ -2668,15 +2336,6 @@
"node": ">=14.0.0" "node": ">=14.0.0"
} }
}, },
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"license": "ISC",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/onetime": { "node_modules/onetime": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
@@ -2721,15 +2380,6 @@
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
"license": "BlueOak-1.0.0" "license": "BlueOak-1.0.0"
}, },
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/path-key": { "node_modules/path-key": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
@@ -2949,20 +2599,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/readable-stream": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
"license": "MIT",
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/real-require": { "node_modules/real-require": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz",
@@ -3016,65 +2652,6 @@
"integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"deprecated": "Rimraf versions prior to v4 are no longer supported",
"license": "ISC",
"dependencies": {
"glob": "^7.1.3"
},
"bin": {
"rimraf": "bin.js"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rimraf/node_modules/brace-expansion": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/rimraf/node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]",
"license": "ISC",
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rimraf/node_modules/minimatch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/rollup": { "node_modules/rollup": {
"version": "4.60.0", "version": "4.60.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.0.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.0.tgz",
@@ -3182,12 +2759,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"license": "ISC"
},
"node_modules/set-cookie-parser": { "node_modules/set-cookie-parser": {
"version": "2.7.2", "version": "2.7.2",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
@@ -3319,15 +2890,6 @@
"reusify": "^1.0.0" "reusify": "^1.0.0"
} }
}, },
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.2.0"
}
},
"node_modules/string-width": { "node_modules/string-width": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
@@ -3450,33 +3012,6 @@
"url": "https://github.com/sponsors/antfu" "url": "https://github.com/sponsors/antfu"
} }
}, },
"node_modules/tar": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
"integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==",
"deprecated": "Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]",
"license": "ISC",
"dependencies": {
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",
"minipass": "^5.0.0",
"minizlib": "^2.1.1",
"mkdirp": "^1.0.3",
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/tar/node_modules/minipass": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz",
"integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==",
"license": "ISC",
"engines": {
"node": ">=8"
}
},
"node_modules/tdigest": { "node_modules/tdigest": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.2.tgz", "resolved": "https://registry.npmjs.org/tdigest/-/tdigest-0.1.2.tgz",
@@ -3540,12 +3075,6 @@
"node": ">=0.6" "node": ">=0.6"
} }
}, },
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/tsx": { "node_modules/tsx": {
"version": "4.21.0", "version": "4.21.0",
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz",
@@ -3598,9 +3127,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.21.0", "version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/uri-js": { "node_modules/uri-js": {
@@ -3612,12 +3141,6 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
"node_modules/vite": { "node_modules/vite": {
"version": "5.4.21", "version": "5.4.21",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
@@ -4197,22 +3720,6 @@
} }
} }
}, },
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -4245,56 +3752,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/wide-align": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
"integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==",
"license": "ISC",
"dependencies": {
"string-width": "^1.0.2 || 2 || 3 || 4"
}
},
"node_modules/wide-align/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/wide-align/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/wide-align/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wide-align/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/wrap-ansi": { "node_modules/wrap-ansi": {
"version": "8.1.0", "version": "8.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
@@ -4398,12 +3855,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"license": "ISC"
},
"node_modules/xtend": { "node_modules/xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
@@ -4413,12 +3864,6 @@
"node": ">=0.4" "node": ">=0.4"
} }
}, },
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"license": "ISC"
},
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.8.3", "version": "2.8.3",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz",
+5 -2
View File
@@ -12,6 +12,9 @@
"test:watch": "vitest", "test:watch": "vitest",
"db:migrate": "bash ../scripts/run-mysql-migrations.sh" "db:migrate": "bash ../scripts/run-mysql-migrations.sh"
}, },
"engines": {
"node": ">=24.22.1"
},
"dependencies": { "dependencies": {
"@fastify/cookie": "^9.3.1", "@fastify/cookie": "^9.3.1",
"@fastify/helmet": "^11.1.1", "@fastify/helmet": "^11.1.1",
@@ -19,7 +22,7 @@
"@fastify/rate-limit": "^9.1.0", "@fastify/rate-limit": "^9.1.0",
"@fastify/swagger": "^8.14.0", "@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^3.0.0", "@fastify/swagger-ui": "^3.0.0",
"bcrypt": "^5.1.1", "bcrypt": "^6.0.0",
"fastify": "^4.28.1", "fastify": "^4.28.1",
"mysql2": "^3.11.5", "mysql2": "^3.11.5",
"pino": "^9.1.0", "pino": "^9.1.0",
@@ -28,7 +31,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/bcrypt": "^5.0.2", "@types/bcrypt": "^5.0.2",
"@types/node": "^20.14.0", "@types/node": "^24.0.0",
"tsx": "^4.15.6", "tsx": "^4.15.6",
"typescript": "^5.4.5", "typescript": "^5.4.5",
"vitest": "^1.6.0" "vitest": "^1.6.0"
+30 -2
View File
@@ -2,17 +2,30 @@
* Known-resolved error patterns for the hub resolve-fixed-patterns endpoint (BIT-25072). * Known-resolved error patterns for the hub resolve-fixed-patterns endpoint (BIT-25072).
* Each entry matches against er_incident_occurrences.message (via LIKE or exact). * Each entry matches against er_incident_occurrences.message (via LIKE or exact).
* *
* Schema: { messagePatterns: string[], note: string } * Schema: { messagePatterns, note, addedAt?, expiresAfterDays? }
* messagePatterns: SQL LIKE patterns (use % wildcards). All patterns in an entry are AND-ed. * messagePatterns: SQL LIKE patterns (use % wildcards). All patterns in an entry are AND-ed.
* note: human-readable reason / fix reference (written to er_incident_state_history.change_note). * note: human-readable reason / fix reference (written to er_incident_state_history.change_note).
* addedAt: ISO date when this pattern was added (YYYY-MM-DD).
* expiresAfterDays: if set, the pattern stops auto-resolving this many days after addedAt.
* This forces errors that persist beyond the grace period back to open state, ensuring the
* fix landed in code and wasn't just hidden. Omit for permanent patterns (transient infra noise
* with no code fix expected). See BIT-26790.
* *
* Transient infrastructure errors: noise from known-bad infra states that self-resolve. * Transient infrastructure errors: noise from known-bad infra states that self-resolve.
* Fixed code errors: added after the fix is deployed to production. * Fixed code errors: added after the fix is deployed to production — set expiresAfterDays.
*/ */
export interface FixedPattern { export interface FixedPattern {
/** Each element becomes: o.message LIKE ? (all AND-ed together for this entry). */ /** Each element becomes: o.message LIKE ? (all AND-ed together for this entry). */
messagePatterns: string[]; messagePatterns: string[];
note: string; note: string;
/** ISO date (YYYY-MM-DD) when this pattern was added. */
addedAt?: string;
/**
* Days after addedAt when this pattern expires and stops auto-resolving.
* Expired patterns are skipped so the error resurfaces if it still occurs,
* signalling that the code fix hasn't landed yet. Omit for permanent patterns.
*/
expiresAfterDays?: number;
} }
const patterns: FixedPattern[] = [ const patterns: FixedPattern[] = [
@@ -20,21 +33,36 @@ const patterns: FixedPattern[] = [
{ {
messagePatterns: ['%WSREP has not yet prepared node%'], messagePatterns: ['%WSREP has not yet prepared node%'],
note: 'Transient: Galera cluster node not ready; infrastructure', note: 'Transient: Galera cluster node not ready; infrastructure',
addedAt: '2026-06-13',
}, },
// Google API backendError — transient external // Google API backendError — transient external
{ {
messagePatterns: ['%Internal error encountered%', '%backendError%'], messagePatterns: ['%Internal error encountered%', '%backendError%'],
note: 'Transient: Google API 500 backendError; external; no code fix', note: 'Transient: Google API 500 backendError; external; no code fix',
addedAt: '2026-06-13',
}, },
// Session write fails when DB is unavailable (cascading) // Session write fails when DB is unavailable (cascading)
{ {
messagePatterns: ['%session_write_close(): Failed to write session data%'], messagePatterns: ['%session_write_close(): Failed to write session data%'],
note: 'Transient: cascades from DB unavailability; no code fix', note: 'Transient: cascades from DB unavailability; no code fix',
addedAt: '2026-06-13',
}, },
// Storage / COMMIT transient // Storage / COMMIT transient
{ {
messagePatterns: ['%No such device or address%'], messagePatterns: ['%No such device or address%'],
note: 'Transient: storage/infrastructure during COMMIT; retry on next request', note: 'Transient: storage/infrastructure during COMMIT; retry on next request',
addedAt: '2026-06-13',
},
// CRM: fix-duplicate-logo.js load failure (BIT-25223 ERRCLUSTER:33b4e527d8fd)
// File is present and protected by CopyWebpackPlugin + deploy gate; client-side noise
// filter (PR #684) suppresses at source. Chrome-style messages include the URL; this
// pattern resolves any that still reach the hub. Firefox-style resolved by bulk-resolve.
// Expires after 14 days — if still occurring after that, the deploy or filter is broken.
{
messagePatterns: ['%fix-duplicate-logo.js%'],
note: 'Fixed: fix-duplicate-logo.js present + protected (BIT-25223); client noise filter PR #684',
addedAt: '2026-07-17',
expiresAfterDays: 14,
}, },
]; ];
+16
View File
@@ -45,6 +45,22 @@ export function authorizeReadQuery(request: FastifyRequest, reply: FastifyReply)
return true; return true;
} }
// BIT-31442: accept X-Api-Key header as an alternative to the query param so
// programmatic callers (Paperclip, QA) can avoid leaking the key in URLs/logs.
// The header may carry either the resolve/reporting key or the read-only
// DEBUG_VIEW_ERRORS_KEY, mirroring the query-param semantics.
const headerRaw = request.headers['x-api-key'];
const headerVal = Array.isArray(headerRaw) ? headerRaw[0] : headerRaw;
const providedHeader = typeof headerVal === 'string' ? headerVal.trim() : '';
if (providedHeader !== '') {
if (apiKey && safeEqual(providedHeader, apiKey)) {
return true;
}
if (viewKey && safeEqual(providedHeader, viewKey)) {
return true;
}
}
reply.code(401).send({ reply.code(401).send({
success: false, success: false,
message: 'Unauthorized', message: 'Unauthorized',
@@ -624,13 +624,33 @@ async function handleResolveFixedPatterns(request: FastifyRequest, reply: Fastif
const dryRun = Boolean(body.dry_run); const dryRun = Boolean(body.dry_run);
const { type, ref } = changedByRef(auth); const { type, ref } = changedByRef(auth);
const details: Array<{ note: string; resolved?: number; would_resolve?: number }> = []; const details: Array<{
note: string;
resolved?: number;
would_resolve?: number;
expired?: boolean;
expires_at?: string;
}> = [];
let total = 0; let total = 0;
let expiredCount = 0;
const nowMs = Date.now();
for (const pattern of fixedPatterns) { for (const pattern of fixedPatterns) {
if (pattern.messagePatterns.length === 0) { if (pattern.messagePatterns.length === 0) {
continue; continue;
} }
// Skip patterns that have passed their expiry window (BIT-26790).
// Expired patterns stop suppressing so the error resurfaces if still present.
if (pattern.addedAt && pattern.expiresAfterDays !== undefined) {
const addedMs = new Date(pattern.addedAt).getTime();
const expiresAt = new Date(addedMs + pattern.expiresAfterDays * 86_400_000);
if (nowMs > expiresAt.getTime()) {
expiredCount += 1;
details.push({ note: pattern.note, expired: true, expires_at: expiresAt.toISOString().slice(0, 10) });
continue;
}
}
const likeClauses = pattern.messagePatterns.map(() => 'o.message LIKE ?').join(' AND '); const likeClauses = pattern.messagePatterns.map(() => 'o.message LIKE ?').join(' AND ');
const params: string[] = pattern.messagePatterns; const params: string[] = pattern.messagePatterns;
@@ -707,13 +727,14 @@ async function handleResolveFixedPatterns(request: FastifyRequest, reply: Fastif
await auditMutation(request.server, request, auth, 'error_monitoring.resolve_fixed_patterns', 'batch', { await auditMutation(request.server, request, auth, 'error_monitoring.resolve_fixed_patterns', 'batch', {
resolved: total, resolved: total,
pattern_count: fixedPatterns.length, pattern_count: fixedPatterns.length,
expired_pattern_count: expiredCount,
}); });
} }
return void reply.send({ return void reply.send({
success: true, success: true,
message: dryRun ? `Would resolve ${total} incidents` : `Resolved ${total} incidents`, message: dryRun ? `Would resolve ${total} incidents` : `Resolved ${total} incidents`,
data: { total, dry_run: dryRun, details }, data: { total, dry_run: dryRun, expired_pattern_count: expiredCount, details },
}); });
} }
+143
View File
@@ -84,4 +84,147 @@ describe('GET /api/error-monitoring/recent-errors', () => {
const body = res.json() as { data: Array<{ gitea_repo?: string }> }; const body = res.json() as { data: Array<{ gitea_repo?: string }> };
expect(body.data[0].gitea_repo).toBeUndefined(); expect(body.data[0].gitea_repo).toBeUndefined();
}); });
it('includes top-level paperclip_project_id when stored in context_json', async () => {
const execute = vi.fn().mockResolvedValue([
[
{
incident_id: '2',
occurrence_id: '100',
project_slug: 'crm',
incident_severity: 'high',
incident_state: 'open',
message: 'probe',
stack_trace: '',
context_json: JSON.stringify({
paperclip_project_id: 'dba3fc26-c728-4e51-a23c-083881a2f534',
}),
environment: 'production',
occurred_at: '2026-01-01T00:00:00.000Z',
} as RowDataPacket,
],
]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors?api_key=test-recent-errors-key',
});
expect(res.statusCode).toBe(200);
const body = res.json() as { data: Array<{ paperclip_project_id?: string }> };
expect(body.data[0].paperclip_project_id).toBe('dba3fc26-c728-4e51-a23c-083881a2f534');
});
it('omits paperclip_project_id when not present in context', async () => {
const execute = vi.fn().mockResolvedValue([
[
{
incident_id: '3',
occurrence_id: '101',
project_slug: 'wdmi-store',
incident_severity: 'low',
incident_state: 'open',
message: 'y',
stack_trace: '',
context_json: JSON.stringify({ project_slug: 'wdmi-store' }),
environment: 'production',
occurred_at: '2026-01-01T00:00:00.000Z',
} as RowDataPacket,
],
]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors?api_key=test-recent-errors-key',
});
expect(res.statusCode).toBe(200);
const body = res.json() as { data: Array<{ paperclip_project_id?: string }> };
expect(body.data[0].paperclip_project_id).toBeUndefined();
});
it('paginates by incident (er_incidents) first when no q is given, incl. status=resolved (BIT-29730)', async () => {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors?status=resolved&limit=50&api_key=test-recent-errors-key',
});
expect(res.statusCode).toBe(200);
expect(execute).toHaveBeenCalledTimes(1);
const [sql, params] = execute.mock.calls[0] as [string, unknown[]];
expect(sql).toContain('selected_incidents');
expect(sql).not.toContain('o.message LIKE');
// ['resolved', limit, offset]
expect(params).toEqual(['resolved', 50, 0]);
});
it('falls back to the occurrence-first scan when q is given', async () => {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors?status=resolved&q=boom&limit=10&api_key=test-recent-errors-key',
});
expect(res.statusCode).toBe(200);
const [sql, params] = execute.mock.calls[0] as [string, unknown[]];
expect(sql).not.toContain('selected_incidents');
expect(sql).toContain('o.message LIKE');
// ['resolved', '%boom%', '%boom%', '%boom%', limit, offset]
expect(params).toEqual(['resolved', '%boom%', '%boom%', '%boom%', 10, 0]);
});
it('serves the /v1/paperclip/recent-errors alias from the same handler (BIT-31442)', async () => {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/v1/paperclip/recent-errors?api_key=test-recent-errors-key',
});
expect(res.statusCode).toBe(200);
expect(execute).toHaveBeenCalledTimes(1);
});
it('accepts the resolve key via X-Api-Key header (BIT-31442)', async () => {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors',
headers: { 'x-api-key': 'test-recent-errors-key' },
});
expect(res.statusCode).toBe(200);
expect(execute).toHaveBeenCalledTimes(1);
});
it('accepts the read-only view key via X-Api-Key header (BIT-31442)', async () => {
const prevView = process.env.DEBUG_VIEW_ERRORS_KEY;
process.env.DEBUG_VIEW_ERRORS_KEY = 'test-view-key';
try {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors',
headers: { 'x-api-key': 'test-view-key' },
});
expect(res.statusCode).toBe(200);
} finally {
if (prevView === undefined) {
delete process.env.DEBUG_VIEW_ERRORS_KEY;
} else {
process.env.DEBUG_VIEW_ERRORS_KEY = prevView;
}
}
});
it('rejects an invalid X-Api-Key header with 401 (BIT-31442)', async () => {
const execute = vi.fn().mockResolvedValue([[]]);
const app = await buildApp(execute);
const res = await app.inject({
method: 'GET',
url: '/api/error-monitoring/recent-errors',
headers: { 'x-api-key': 'wrong-key' },
});
expect(res.statusCode).toBe(401);
expect(execute).not.toHaveBeenCalled();
});
}); });
+123 -15
View File
@@ -65,6 +65,15 @@ function extractFileLine(ctx: Record<string, unknown> | null): { file_path: stri
return { file_path, line_number }; return { file_path, line_number };
} }
function ctxStr(ctx: Record<string, unknown> | null, keys: string[]): string {
if (!ctx) return '';
for (const k of keys) {
const v = ctx[k];
if (typeof v === 'string' && v.trim() !== '') return v.trim();
}
return '';
}
/** Paperclip error loop reads top-level `gitea_repo` on each recent-error row. */ /** Paperclip error loop reads top-level `gitea_repo` on each recent-error row. */
function extractGiteaRepo(ctx: Record<string, unknown> | null): string { function extractGiteaRepo(ctx: Record<string, unknown> | null): string {
if (!ctx) { if (!ctx) {
@@ -74,6 +83,15 @@ function extractGiteaRepo(ctx: Record<string, unknown> | null): string {
return typeof raw === 'string' ? raw.trim() : ''; return typeof raw === 'string' ? raw.trim() : '';
} }
/** Paperclip error loop reads top-level `paperclip_project_id` to route issues to the correct project. */
function extractPaperclipProjectId(ctx: Record<string, unknown> | null): string {
if (!ctx) {
return '';
}
const raw = ctx.paperclip_project_id ?? ctx.paperclipProjectId;
return typeof raw === 'string' ? raw.trim() : '';
}
function parseStatusList(raw: string | undefined): string[] | null { function parseStatusList(raw: string | undefined): string[] | null {
if (raw == null || raw.trim() === '') { if (raw == null || raw.trim() === '') {
return ['open', 'investigating']; return ['open', 'investigating'];
@@ -91,6 +109,29 @@ function parseStatusList(raw: string | undefined): string[] | null {
return parts.length > 0 ? parts : ['open', 'investigating']; return parts.length > 0 ? parts : ['open', 'investigating'];
} }
function slimContext(ctx: Record<string, unknown> | null): Record<string, unknown> | null {
if (!ctx) return null;
const out: Record<string, unknown> = {};
for (const key of Object.keys(ctx).slice(0, 40)) out[key] = slimContextValue(ctx[key], 0);
return out;
}
function slimContextValue(value: unknown, depth: number): unknown {
if (depth > 3) return '[nested]';
if (typeof value === 'string') return value.length > 1500 ? `${value.slice(0, 1500)}…` : value;
if (value == null || typeof value === 'number' || typeof value === 'boolean') return value;
if (Array.isArray(value)) return value.slice(0, 20).map((item) => slimContextValue(item, depth + 1));
if (typeof value === 'object') {
const nested: Record<string, unknown> = {};
for (const [key, item] of Object.entries(value as Record<string, unknown>).slice(0, 30)) {
nested[key] = slimContextValue(item, depth + 1);
}
return nested;
}
return String(value).slice(0, 500);
}
async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply): Promise<void> { async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply): Promise<void> {
const db = request.server.db; const db = request.server.db;
@@ -149,28 +190,80 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply):
orderRaw === 'occurred_at_asc' ? 'r.occurred_at ASC, r.id ASC' : 'r.occurred_at DESC, r.id DESC'; orderRaw === 'occurred_at_asc' ? 'r.occurred_at ASC, r.id ASC' : 'r.occurred_at DESC, r.id DESC';
const statePlaceholders = states.map(() => '?').join(', '); const statePlaceholders = states.map(() => '?').join(', ');
const conditions: string[] = [`i.current_state IN (${statePlaceholders})`]; const incidentConditions: string[] = [`i.current_state IN (${statePlaceholders})`];
const params: Array<string | number> = [...states]; const incidentParams: Array<string | number> = [...states];
if (q.severity != null && q.severity !== '') { if (q.severity != null && q.severity !== '') {
conditions.push('i.severity = ?'); incidentConditions.push('i.severity = ?');
params.push(q.severity.trim().toLowerCase()); incidentParams.push(q.severity.trim().toLowerCase());
} }
if (q.project_slug != null && q.project_slug.trim() !== '') { if (q.project_slug != null && q.project_slug.trim() !== '') {
conditions.push('p.slug = ?'); incidentConditions.push('p.slug = ?');
params.push(q.project_slug.trim().toLowerCase()); incidentParams.push(q.project_slug.trim().toLowerCase());
} }
if (q.q != null && q.q.trim() !== '') { const incidentWhereClause = incidentConditions.join(' AND ');
const term = `%${q.q.trim()}%`; const hasSearch = q.q != null && q.q.trim() !== '';
conditions.push('(i.title LIKE ? OR o.message LIKE ? OR i.fingerprint LIKE ?)');
params.push(term, term, term);
}
const whereClause = conditions.join(' AND '); let sql: string;
let params: Array<string | number>;
const sql = ` if (!hasSearch) {
// Fast path (BIT-29730, tightened in BIT-30040): page through er_incidents
// first (small, indexed by current_state) and fetch only the single latest
// occurrence per selected incident via a correlated subquery. Earlier this
// still used ROW_NUMBER() over ALL occurrences of the selected incidents —
// MariaDB can't turn PARTITION BY into a loose index scan, so it
// materialized and sorted the entire occurrence history of every matching
// incident before filtering rn = 1. Fleet-audit-scale "mega-incidents"
// (100k+ occurrences each) blew that up to minutes even after the
// incident-first paging fix. A `LIMIT 1` correlated subquery per incident
// instead walks er_incident_occurrences_incident_time_idx
// (incident_id, occurred_at DESC) and stops at the first row — no
// materialization of the rest of that incident's history.
const incidentOrderDir = orderRaw === 'occurred_at_asc' ? 'ASC' : 'DESC';
sql = `
WITH selected_incidents AS (
SELECT i.id AS incident_id
FROM er_incidents i
INNER JOIN er_projects p ON p.id = i.project_id
WHERE ${incidentWhereClause}
ORDER BY i.last_seen_at ${incidentOrderDir}, i.id ${incidentOrderDir}
LIMIT ? OFFSET ?
)
SELECT CAST(i.id AS CHAR) AS incident_id,
CAST(r.id AS CHAR) AS occurrence_id,
p.slug AS project_slug,
i.severity AS incident_severity,
i.current_state AS incident_state,
r.message,
r.stack_trace,
r.context_json,
r.environment,
r.occurred_at
FROM selected_incidents si
INNER JOIN er_incidents i ON i.id = si.incident_id
INNER JOIN er_projects p ON p.id = i.project_id
INNER JOIN er_incident_occurrences r ON r.id = (
SELECT o.id
FROM er_incident_occurrences o
WHERE o.incident_id = si.incident_id
ORDER BY o.occurred_at DESC, o.id DESC
LIMIT 1
)
ORDER BY ${orderSql}
`;
params = [...incidentParams, limit, offset];
} else {
// Search path: `q` matches against occurrence message too, so an incident's
// latest occurrence isn't necessarily the one that matched. Keep the
// original occurrence-first scan for correctness; status=resolved + q can
// still be slow (not the case reported in BIT-29730, tracked separately).
const term = `%${q.q!.trim()}%`;
const conditions = [...incidentConditions, '(i.title LIKE ? OR o.message LIKE ? OR i.fingerprint LIKE ?)'];
const whereClause = conditions.join(' AND ');
sql = `
WITH ranked AS ( WITH ranked AS (
SELECT o.id, SELECT o.id,
o.incident_id, o.incident_id,
@@ -202,8 +295,8 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply):
ORDER BY ${orderSql} ORDER BY ${orderSql}
LIMIT ? OFFSET ? LIMIT ? OFFSET ?
`; `;
params = [...incidentParams, term, term, term, limit, offset];
params.push(limit, offset); }
const [rows] = await db.execute<RowDataPacket[]>(sql, params); const [rows] = await db.execute<RowDataPacket[]>(sql, params);
@@ -211,6 +304,7 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply):
const ctx = parseJsonObject(row.context_json != null ? String(row.context_json) : null); const ctx = parseJsonObject(row.context_json != null ? String(row.context_json) : null);
const { file_path, line_number } = extractFileLine(ctx); const { file_path, line_number } = extractFileLine(ctx);
const gitea_repo = extractGiteaRepo(ctx); const gitea_repo = extractGiteaRepo(ctx);
const paperclip_project_id = extractPaperclipProjectId(ctx);
const incSev = String(row.incident_severity ?? 'medium').toLowerCase(); const incSev = String(row.incident_severity ?? 'medium').toLowerCase();
const sev = ['critical', 'high', 'medium', 'low'].includes(incSev) ? incSev : 'medium'; const sev = ['critical', 'high', 'medium', 'low'].includes(incSev) ? incSev : 'medium';
const st = String(row.incident_state ?? 'open').toLowerCase(); const st = String(row.incident_state ?? 'open').toLowerCase();
@@ -238,6 +332,20 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply):
if (gitea_repo !== '') { if (gitea_repo !== '') {
rowOut.gitea_repo = gitea_repo; rowOut.gitea_repo = gitea_repo;
} }
const extra: Record<string, string> = {
component: ctxStr(ctx, ['component']),
release_version: ctxStr(ctx, ['release_version', 'release', 'app_version']),
runtime_name: ctxStr(ctx, ['runtime_name', 'runtime']),
host_name: ctxStr(ctx, ['host_name', 'hostname', 'host']),
};
for (const [k, v] of Object.entries(extra)) {
if (v !== '') rowOut[k] = v;
}
if (paperclip_project_id !== '') {
rowOut.paperclip_project_id = paperclip_project_id;
}
const contextData = slimContext(ctx);
if (contextData) rowOut.context_data = contextData;
return rowOut; return rowOut;
}); });
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* BitReport Error Reporter — lightweight Node.js client for errors.bitreport.pt * BitReport Error Reporter — lightweight Node.js client for errors.bitreport.pt
* *
* Zero dependencies (uses native fetch). Drop this file into any Node.js 18+ project. * Zero dependencies (uses native fetch). Drop this file into any Node.js 24+ project.
* *
* Usage: * Usage:
* import { initReporter, reportError, reportMessage } from './errorReporter.mjs'; * import { initReporter, reportError, reportMessage } from './errorReporter.mjs';
+1 -1
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
/** /**
* BitReport Error Reporter — PHP client for errors.bitreport.pt ingest API. * BitReport Error Reporter — PHP client for errors.bitreport.pt ingest API.
* *
* Drop this file into any PHP 8+ project. No Composer dependencies. * Drop this file into any PHP 8.4+ project. No Composer dependencies.
* *
* Usage: * Usage:
* require_once __DIR__ . '/ErrorReporter.php'; * require_once __DIR__ . '/ErrorReporter.php';
+2 -2
View File
@@ -1,4 +1,4 @@
FROM node:20-bookworm-slim AS build FROM node:24-bookworm-slim AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
@@ -6,7 +6,7 @@ COPY tsconfig.json ./
COPY src ./src COPY src ./src
RUN npm run build RUN npm run build
FROM node:20-bookworm-slim FROM node:24-bookworm-slim
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
+9 -9
View File
@@ -12,13 +12,13 @@
"mysql2": "^3.11.5" "mysql2": "^3.11.5"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vitest": "^2.1.0" "vitest": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
@@ -828,12 +828,12 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.19.15", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.15.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
"integrity": "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==", "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": ">=7.24.0 <7.24.7"
} }
}, },
"node_modules/@vitest/expect": { "node_modules/@vitest/expect": {
@@ -1519,9 +1519,9 @@
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.21.0", "version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/vite": { "node_modules/vite": {
+2 -2
View File
@@ -16,12 +16,12 @@
"mysql2": "^3.11.5" "mysql2": "^3.11.5"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vitest": "^2.1.0" "vitest": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
} }
@@ -0,0 +1,5 @@
BEGIN;
DROP INDEX IF EXISTS er_incidents_state_seen_idx ON er_incidents;
COMMIT;
@@ -0,0 +1,11 @@
BEGIN;
-- BIT-29730: GET /api/error-monitoring/recent-errors timed out for status=resolved.
-- er_incidents_project_state_seen_idx (project_id, current_state, last_seen_at DESC)
-- only helps when project_slug is also filtered. recent-errors now filters/paginates
-- er_incidents by current_state alone (no project_id) before touching occurrences,
-- so add a state-only index to support that lookup.
CREATE INDEX IF NOT EXISTS er_incidents_state_seen_idx
ON er_incidents (current_state, last_seen_at DESC);
COMMIT;
+1
View File
@@ -58,6 +58,7 @@ _run_sql "${_MIG_ER}/20260322045000_create_collectors_retention_and_audit.up.sql
_run_sql "${_MIG_ER}/20260402103000_add_occurred_at_for_stats.up.sql" _run_sql "${_MIG_ER}/20260402103000_add_occurred_at_for_stats.up.sql"
_run_sql "${_MIG_ER}/20260402140000_ingest_key_rate_limits.up.sql" _run_sql "${_MIG_ER}/20260402140000_ingest_key_rate_limits.up.sql"
_run_sql "${_MIG_ER}/20260608150000_retire_wdmi_projects.up.sql" _run_sql "${_MIG_ER}/20260608150000_retire_wdmi_projects.up.sql"
_run_sql "${_MIG_ER}/20260824120000_add_incidents_state_seen_idx.up.sql"
_run_sql "${_MIG_ADMIN}/001_admin_users.sql" _run_sql "${_MIG_ADMIN}/001_admin_users.sql"
_run_sql "${_MIG_ADMIN}/002_admin_refresh_tokens.sql" _run_sql "${_MIG_ADMIN}/002_admin_refresh_tokens.sql"
_run_sql "${_MIG_ADMIN}/003_audit_logs.sql" _run_sql "${_MIG_ADMIN}/003_audit_logs.sql"
+26 -4
View File
@@ -27,10 +27,10 @@ git checkout "${_DEPLOY_BRANCH}"
git merge --ff-only "origin/${_DEPLOY_BRANCH}" git merge --ff-only "origin/${_DEPLOY_BRANCH}"
echo "webhook-deploy: npm ci + build (ingest-api, admin-ui, collector-worker, api)" echo "webhook-deploy: npm ci + build (ingest-api, admin-ui, collector-worker, api)"
(cd "${_ROOT}/ingest-api" && npm ci && npm run build) (cd "${_ROOT}/ingest-api" && npm ci --include=dev && npm run build)
(cd "${_ROOT}/admin-ui" && npm ci && npm run build) (cd "${_ROOT}/admin-ui" && npm ci --include=dev && npm run build)
(cd "${_ROOT}/collector-worker" && npm ci && npm run build) (cd "${_ROOT}/collector-worker" && npm ci --include=dev && npm run build)
(cd "${_ROOT}/api" && npm ci && npm run build) (cd "${_ROOT}/api" && npm ci --include=dev && npm run build)
if getent passwd error-reporting >/dev/null 2>&1; then if getent passwd error-reporting >/dev/null 2>&1; then
chown -R error-reporting:error-reporting "${_ROOT}" chown -R error-reporting:error-reporting "${_ROOT}"
@@ -44,6 +44,28 @@ if [[ "${ER_WEBHOOK_RESTART_SERVICES:-1}" == "1" ]]; then
systemctl restart bitreport-error-reporting-admin-ui.service systemctl restart bitreport-error-reporting-admin-ui.service
systemctl restart bitreport-error-reporting-collector-worker.service systemctl restart bitreport-error-reporting-collector-worker.service
systemctl restart bitreport-error-reporting-api.service systemctl restart bitreport-error-reporting-api.service
# Auto-apply resolve-fixed-patterns after every deploy so code fixes clear stale incidents.
if [[ -n "${ERROR_RESOLVE_API_KEY:-}" ]]; then
_api_port="${ER_API_PORT:-3200}"
_ready=0
for _i in $(seq 1 20); do
if curl -sf "http://localhost:${_api_port}/health" >/dev/null 2>&1; then
_ready=1; break
fi
sleep 3
done
if [[ "${_ready}" == "1" ]]; then
curl -sf -X POST "http://localhost:${_api_port}/api/error-monitoring/resolve-fixed-patterns" \
-H "Content-Type: application/json" \
-d "{\"api_key\":\"${ERROR_RESOLVE_API_KEY}\"}" \
>/dev/null 2>&1 \
&& echo "webhook-deploy: resolve-fixed-patterns applied" \
|| echo "webhook-deploy: WARN resolve-fixed-patterns failed (non-fatal)"
else
echo "webhook-deploy: WARN API not ready after 60s, skipping resolve-fixed-patterns"
fi
fi
fi fi
echo "webhook-deploy: done" echo "webhook-deploy: done"
+4
View File
@@ -59,6 +59,10 @@ Alias: `GET /v1/paperclip/recent-errors` (same handler).
**Query:** `api_key` *or* `view_errors`, plus optional `limit`, `offset`, `status`, `severity`, `project_slug`, `q`, `order`. **Query:** `api_key` *or* `view_errors`, plus optional `limit`, `offset`, `status`, `severity`, `project_slug`, `q`, `order`.
**Header (BIT-31442):** `X-Api-Key: <key>` is accepted as an alternative to the `api_key`/`view_errors` query params, so programmatic callers can avoid leaking the key in URLs and access logs. The header may carry either `ERROR_RESOLVE_API_KEY`/`ERROR_REPORTING_API_KEY` or the read-only `DEBUG_VIEW_ERRORS_KEY`.
> **Proxy note (BIT-31442):** the `/v1/paperclip/*` alias is served by the admin API (port 3200), not ingest-api (port 3041). The `admin-ui` Next.js rewrite routes `/v1/paperclip/:path*` to the admin API *before* the generic `/v1/:path*` → ingest-api rule. If the alias returns 404 in production, verify that rewrite order in `admin-ui/next.config.ts`.
**Response 200** **Response 200**
```json ```json
+2 -2
View File
@@ -72,7 +72,7 @@ Automation or Grafana can **poll** that endpoint on an interval (with read key)
|--------|--------|---------| |--------|--------|---------|
| `er_ingest_request_duration_seconds` | `status_code` | End-to-end POST latency (SLO: watch p95/p99) | | `er_ingest_request_duration_seconds` | `status_code` | End-to-end POST latency (SLO: watch p95/p99) |
| `er_ingest_requests_total` | `status_code` | Request volume by outcome class | | `er_ingest_requests_total` | `status_code` | Request volume by outcome class |
| `er_ingest_events_total` | `outcome` | `stored`, `skipped_noise`, `error` | | `er_ingest_events_total` | `outcome`, `rule_id` | `stored` / `error` use empty `rule_id`; `skipped_noise` sets noise policy id (e.g. `resize_observer_loop`) |
| `er_ingest_batch_size` | — | Histogram of events per request | | `er_ingest_batch_size` | — | Histogram of events per request |
| `er_ingest_active_connections` | — | In-flight requests (gauge) | | `er_ingest_active_connections` | — | In-flight requests (gauge) |
@@ -84,7 +84,7 @@ Plus `er_ingest_*` process defaults from `prom-client`.
1. **Ingest availability:** `sum(rate(er_ingest_requests_total[5m])) by (status_code)`. 1. **Ingest availability:** `sum(rate(er_ingest_requests_total[5m])) by (status_code)`.
2. **Ingest latency:** histogram quantiles on `er_ingest_request_duration_seconds` (e.g. `histogram_quantile(0.95, …)`). 2. **Ingest latency:** histogram quantiles on `er_ingest_request_duration_seconds` (e.g. `histogram_quantile(0.95, …)`).
3. **Noise vs stored:** `rate(er_ingest_events_total{outcome="stored"}[5m])` vs `skipped_noise`. 3. **Noise vs stored:** `rate(er_ingest_events_total{outcome="stored"}[5m])` vs `skipped_noise`. Per-rule noise: `sum(rate(er_ingest_events_total{outcome="skipped_noise"}[5m])) by (rule_id)`.
4. **Open incidents:** `er_incidents_total` by `state` (after stats refresh). 4. **Open incidents:** `er_incidents_total` by `state` (after stats refresh).
5. **Hub HTTP errors:** `sum(rate(er_api_http_requests_total{status_code=~"5.."}[5m]))`. 5. **Hub HTTP errors:** `sum(rate(er_api_http_requests_total{status_code=~"5.."}[5m]))`.
+1 -1
View File
@@ -121,7 +121,7 @@ When **`Idempotency-Key`** is reused with a **different** JSON body, the API ret
## 7. Noise rules — events “disappear” ## 7. Noise rules — events “disappear”
If the response shows `results[]` entries with `"skipped": true`, the event matched a **noise rule** (`rule_id`, `reason`). This is expected for filtered traffic. Check `noise_filtered_count` and compare with `er_ingest_events_total{outcome="skipped_noise"}` in Prometheus. If the response shows `results[]` entries with `"skipped": true`, the event matched a **noise rule** (`rule_id`, `reason`). This is expected for filtered traffic. Check `noise_filtered_count` and compare with `er_ingest_events_total{outcome="skipped_noise"}` in Prometheus (series also carry `rule_id`).
--- ---
+3
View File
@@ -203,6 +203,9 @@ scrape_configs:
# Ingest throughput (events/sec) # Ingest throughput (events/sec)
sum(rate(er_ingest_events_total[5m])) by (outcome) sum(rate(er_ingest_events_total[5m])) by (outcome)
# Noise skips by rule (BIT-26791)
sum(rate(er_ingest_events_total{outcome="skipped_noise"}[5m])) by (rule_id)
# Ingest request rate by status # Ingest request rate by status
sum(rate(er_ingest_requests_total[5m])) by (status_code) sum(rate(er_ingest_requests_total[5m])) by (status_code)
+1 -1
View File
@@ -32,7 +32,7 @@ Per-key overrides: set `rate_limit_max` and/or `rate_limit_window_ms` on the key
- Rules live in `ingest-api/src/lib/noisePolicy.ts`; ruleset id: `noise_ruleset_version` in the ingest response. - 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 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](../RUNBOOK_INGEST_DEBUG.md) §0) is also skipped at every level with the same `rule_id`. - **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](../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 ## Rate limits
+4 -1
View File
@@ -50,11 +50,14 @@ These routes mirror the CRM error-monitoring module for Paperclip and automation
### Read: `GET /api/error-monitoring/recent-errors` ### Read: `GET /api/error-monitoring/recent-errors`
Alias: `GET /v1/paperclip/recent-errors` (same handler; served by the admin API via the `admin-ui` rewrite — BIT-31442).
| Credential | Notes | | Credential | Notes |
|------------|--------| |------------|--------|
| `api_key` query | Must match `ERROR_RESOLVE_API_KEY` or `ERROR_REPORTING_API_KEY` | | `api_key` query | Must match `ERROR_RESOLVE_API_KEY` or `ERROR_REPORTING_API_KEY` |
| `view_errors` query | Must match `DEBUG_VIEW_ERRORS_KEY` (read-oriented) | | `view_errors` query | Must match `DEBUG_VIEW_ERRORS_KEY` (read-oriented) |
| Admin session | Not used on this path; query credentials only | | `X-Api-Key` header (BIT-31442) | Carries either the resolve/reporting key or `DEBUG_VIEW_ERRORS_KEY`; alternative to the query params to avoid key leakage in URLs/logs |
| Admin session | Not used on this path; query/header credentials only |
At least one of the server secrets above must be configured or the endpoint returns **503**. At least one of the server secrets above must be configured or the endpoint returns **503**.
+2 -2
View File
@@ -1,4 +1,4 @@
FROM node:20-bookworm-slim AS build FROM node:24-bookworm-slim AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
@@ -6,7 +6,7 @@ COPY tsconfig.json ./
COPY src ./src COPY src ./src
RUN npm run build RUN npm run build
FROM node:20-bookworm-slim FROM node:24-bookworm-slim
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
+9 -9
View File
@@ -16,14 +16,14 @@
"prom-client": "^15.1.3" "prom-client": "^15.1.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"ajv": "^8.18.0", "ajv": "^8.18.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vitest": "^2.1.0" "vitest": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
@@ -981,12 +981,12 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.19.15", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.15.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
"integrity": "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg==", "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": ">=7.24.0 <7.24.7"
} }
}, },
"node_modules/@vitest/expect": { "node_modules/@vitest/expect": {
@@ -2638,9 +2638,9 @@
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.21.0", "version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/uri-js": { "node_modules/uri-js": {
+2 -2
View File
@@ -21,13 +21,13 @@
"prom-client": "^15.1.3" "prom-client": "^15.1.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"ajv": "^8.18.0", "ajv": "^8.18.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vitest": "^2.1.0" "vitest": "^2.1.0"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
} }
+15 -7
View File
@@ -239,16 +239,20 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
idempotencyKey: _idempotencyKey, idempotencyKey: _idempotencyKey,
bodyHash: _bodyHash, bodyHash: _bodyHash,
}); });
// Track event outcomes // Track event outcomes (rule_id on skipped_noise for BIT-26791)
if (_out.body && typeof _out.body === "object" && "results" in _out.body) { if (_out.body && typeof _out.body === "object" && "results" in _out.body) {
const results = (_out.body as { results: Array<{ skipped?: boolean }> }).results; const results = (
_out.body as { results: Array<{ skipped?: boolean; rule_id?: string }> }
).results;
let stored = 0; let stored = 0;
let skipped = 0;
let _maxOccurredSec = 0; let _maxOccurredSec = 0;
const skippedByRule = new Map<string, number>();
for (let _i = 0; _i < results.length; _i++) { for (let _i = 0; _i < results.length; _i++) {
const r = results[_i]!; const r = results[_i]!;
if (r.skipped) { if (r.skipped) {
skipped++; const _ruleId =
typeof r.rule_id === "string" && r.rule_id !== "" ? r.rule_id : "unknown";
skippedByRule.set(_ruleId, (skippedByRule.get(_ruleId) ?? 0) + 1);
continue; continue;
} }
stored++; stored++;
@@ -262,8 +266,12 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
} }
} }
} }
if (stored > 0) ingestEventsTotal.inc({ outcome: "stored" }, stored); if (stored > 0) {
if (skipped > 0) ingestEventsTotal.inc({ outcome: "skipped_noise" }, skipped); ingestEventsTotal.inc({ outcome: "stored", rule_id: "" }, stored);
}
for (const [_ruleId, _n] of skippedByRule) {
ingestEventsTotal.inc({ outcome: "skipped_noise", rule_id: _ruleId }, _n);
}
const _slug = request.ingestAuth.projectSlug; const _slug = request.ingestAuth.projectSlug;
if (_slug !== "" && _maxOccurredSec > 0) { if (_slug !== "" && _maxOccurredSec > 0) {
errorHubLastEventTimestamp.set({ project_slug: _slug }, _maxOccurredSec); errorHubLastEventTimestamp.set({ project_slug: _slug }, _maxOccurredSec);
@@ -284,7 +292,7 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
message: "occurred_at must be a valid ISO-8601 timestamp.", message: "occurred_at must be a valid ISO-8601 timestamp.",
}); });
} }
ingestEventsTotal.inc({ outcome: "error" }, _body.events.length); ingestEventsTotal.inc({ outcome: "error", rule_id: "" }, _body.events.length);
const _slugErr = request.ingestAuth?.projectSlug ?? ""; const _slugErr = request.ingestAuth?.projectSlug ?? "";
if (_slugErr !== "") { if (_slugErr !== "") {
errorHubIngestFailuresTotal.inc({ project_slug: _slugErr }, _body.events.length); errorHubIngestFailuresTotal.inc({ project_slug: _slugErr }, _body.events.length);
@@ -242,6 +242,11 @@ describe.skipIf(!_testUrl)("two-project passive ingest (BIT-179)", () => {
expect(_body.noise_filtered_count).toBe(1); expect(_body.noise_filtered_count).toBe(1);
expect(_body.results[0]?.skipped).toBe(true); expect(_body.results[0]?.skipped).toBe(true);
expect(_body.results[0]?.rule_id).toBe("resize_observer_loop"); expect(_body.results[0]?.rule_id).toBe("resize_observer_loop");
const _metrics = await _app.inject({ method: "GET", url: "/metrics" });
expect(_metrics.statusCode).toBe(200);
expect(_metrics.body).toContain(
'er_ingest_events_total{outcome="skipped_noise",rule_id="resize_observer_loop"}',
);
const [after] = await _pool.execute<RowDataPacket[]>( const [after] = await _pool.execute<RowDataPacket[]>(
`SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`, `SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`,
[_projectIdA], [_projectIdA],
+48
View File
@@ -143,6 +143,54 @@ describe("evaluateNoise", () => {
}); });
}); });
it("matches bare 'BIT-<id> smoke test' pipe-liveness probe (BIT-32681)", () => {
const _r = evaluateNoise({
level: "error",
message: "BIT-32663 smoke test",
filePathHint: "",
});
expect(_r).toEqual({
matched: true,
ruleId: "bitreport_smoke_marker",
reason: "filtered_intentional_smoke_event",
});
});
it("matches bracketed '[BIT-<id>] ... smoke test' probe (fleet-audit synthetic form)", () => {
const _r = evaluateNoise({
level: "error",
message: "[BIT-30527] paperclip-chat pipe-liveness smoke test",
filePathHint: "",
});
expect(_r).toEqual({
matched: true,
ruleId: "bitreport_smoke_marker",
reason: "filtered_intentional_smoke_event",
});
});
it("suppresses 'BIT-<id> smoke test' probe even at critical level", () => {
const _r = evaluateNoise({
level: "critical",
message: "BIT-32663 smoke test",
filePathHint: "",
});
expect(_r).toEqual({
matched: true,
ruleId: "bitreport_smoke_marker",
reason: "filtered_intentional_smoke_event",
});
});
it("does not match a real error that merely contains 'smoke' without the BIT-<id> probe shape", () => {
const _r = evaluateNoise({
level: "error",
message: "Smoke detector sensor offline",
filePathHint: "",
});
expect(_r).toEqual({ matched: false });
});
it("matches CRM deploy ingest live-check failure ribbon (BIT-931 family)", () => { it("matches CRM deploy ingest live-check failure ribbon (BIT-931 family)", () => {
const _r = evaluateNoise({ const _r = evaluateNoise({
level: "critical", level: "critical",
+17 -13
View File
@@ -4,7 +4,7 @@ import { normalizeLevelToSeverity } from "./normalize.js";
* Versioned ruleset id (document in release notes when rules change). * Versioned ruleset id (document in release notes when rules change).
* Rule inventory and validation steps: `docs/operations/ingest-hardening-runbook.md`. * Rule inventory and validation steps: `docs/operations/ingest-hardening-runbook.md`.
*/ */
export const NOISE_RULESET_VERSION = "1.0.6"; export const NOISE_RULESET_VERSION = "1.0.8";
export type NoiseEvaluation = export type NoiseEvaluation =
| { matched: false } | { matched: false }
@@ -12,6 +12,15 @@ export type NoiseEvaluation =
const _DEPLOY_INGEST_PROBE_MESSAGE = "BIT-SMOKE error hub ingest live check"; const _DEPLOY_INGEST_PROBE_MESSAGE = "BIT-SMOKE error hub ingest live check";
/**
* Hand-sent pipe-liveness probes referenced by a BIT task id (e.g. `BIT-32663 smoke test`
* or `[BIT-30527] paperclip-chat pipe-liveness smoke test`). The fleet audit already
* treats the bracketed form as synthetic (`_SYNTHETIC_EVENT_RE`); ingest must agree so
* these probes do not open Error Loop issues. Matched at every severity, like `BIT-SMOKE-`.
* BIT-32681 / ERRCLUSTER a513bc4e4505.
*/
const _BIT_ID_SMOKE_PROBE_RE = /\[?BIT-\d+\]?\s+.*smoke test/i;
/** /**
* CRM / editor copy-paste sometimes inserts unicode hyphens (U+2011 etc.) in the reserved * CRM / editor copy-paste sometimes inserts unicode hyphens (U+2011 etc.) in the reserved
* `BIT-SMOKE-` token; strip ZW* / BOM so probes still match `bitreport_smoke_marker` (BIT-933). * `BIT-SMOKE-` token; strip ZW* / BOM so probes still match `bitreport_smoke_marker` (BIT-933).
@@ -104,18 +113,6 @@ const _RULES: NoiseRule[] = [
"Uncaught TypeError: Cannot read properties of undefined (reading 'after')", "Uncaught TypeError: Cannot read properties of undefined (reading 'after')",
), ),
}, },
{
id: "stale_bundle_switch_selection_tab",
reason: "filtered_stale_frontend_bundle_noise",
match: (i) =>
i.message.includes("Uncaught ReferenceError: switchSelectionEditorTab is not defined"),
},
{
id: "stale_bundle_description_editor_ready",
reason: "filtered_stale_frontend_bundle_noise",
match: (i) =>
i.message.includes("Uncaught ReferenceError: descriptionEditorReady is not defined"),
},
{ {
id: "transient_parser_promise", id: "transient_parser_promise",
reason: "filtered_transient_frontend_noise", reason: "filtered_transient_frontend_noise",
@@ -167,6 +164,13 @@ export function evaluateNoise(input: {
reason: "filtered_intentional_smoke_event", reason: "filtered_intentional_smoke_event",
}; };
} }
if (_BIT_ID_SMOKE_PROBE_RE.test(_msg) || _BIT_ID_SMOKE_PROBE_RE.test(_stack)) {
return {
matched: true,
ruleId: "bitreport_smoke_marker",
reason: "filtered_intentional_smoke_event",
};
}
const _sev = normalizeLevelToSeverity(input.level); const _sev = normalizeLevelToSeverity(input.level);
if (_sev === "critical") { if (_sev === "critical") {
return { matched: false }; return { matched: false };
@@ -0,0 +1,15 @@
import { describe, expect, it } from "vitest";
import { ingestEventsTotal, prometheusRegistry } from "./prometheus.js";
describe("er_ingest_events_total rule_id label (BIT-26791)", () => {
it("records skipped_noise with rule_id", async () => {
ingestEventsTotal.inc(
{ outcome: "skipped_noise", rule_id: "resize_observer_loop" },
1,
);
const _text = await prometheusRegistry.metrics();
expect(_text).toContain(
'er_ingest_events_total{outcome="skipped_noise",rule_id="resize_observer_loop"}',
);
});
});
+2 -1
View File
@@ -34,7 +34,8 @@ export const ingestDuration = new Histogram({
export const ingestEventsTotal = new Counter({ export const ingestEventsTotal = new Counter({
name: "er_ingest_events_total", name: "er_ingest_events_total",
help: "Total events ingested", help: "Total events ingested",
labelNames: ["outcome"] as const, // stored, skipped_noise, error // rule_id is set for skipped_noise (noise policy id); empty for stored/error
labelNames: ["outcome", "rule_id"] as const,
registers: [register], registers: [register],
}); });
@@ -0,0 +1,27 @@
import { describe, expect, it } from "vitest";
import { extractOccurrenceMetadata } from "./processIngestBatch.js";
describe("extractOccurrenceMetadata (BIT-33316)", () => {
it("maps canonical keys", () => {
const m = extractOccurrenceMetadata({}, {
runtime_name: "php", runtime_version: "8.3", host_name: "h1",
release_version: "1.2.3", request_id: "r1", environment: "Staging",
});
expect(m).toEqual({
environment: "staging", runtime_name: "php", runtime_version: "8.3",
host_name: "h1", release_version: "1.2.3", request_id: "r1",
});
});
it("falls back to legacy aliases and production", () => {
const m = extractOccurrenceMetadata({}, { hostname: "h2", app_version: "9" });
expect(m.host_name).toBe("h2");
expect(m.release_version).toBe("9");
expect(m.environment).toBe("production");
expect(m.runtime_name).toBeNull();
});
it("event.environment wins, invalid falls back", () => {
expect(extractOccurrenceMetadata({ environment: "dev" }, { environment: "x" }).environment).toBe("dev");
expect(extractOccurrenceMetadata({}, { environment: "bad env!" }).environment).toBe("production");
expect(extractOccurrenceMetadata({}, null).host_name).toBeNull();
});
});
+49 -2
View File
@@ -232,6 +232,44 @@ export async function processIngestBatch(input: {
} }
} }
const _META_ENV_RE = /^[A-Za-z0-9._-]{1,32}$/;
function _metaStr(ctx: Record<string, unknown> | null, keys: string[], max: number): string | null {
if (!ctx) return null;
for (const k of keys) {
const v = ctx[k];
if (typeof v === "string" && v.trim() !== "") return v.trim().slice(0, max);
}
return null;
}
/** Canonical keys first, legacy aliases (hostname, app_version, ...) as fallback. BIT-33316. */
export function extractOccurrenceMetadata(
ev: unknown,
ctx: Record<string, unknown> | null,
): {
environment: string;
runtime_name: string | null;
runtime_version: string | null;
host_name: string | null;
release_version: string | null;
request_id: string | null;
} {
const evObj = (ev && typeof ev === "object" ? ev : {}) as Record<string, unknown>;
const rawEnv =
(typeof evObj.environment === "string" ? evObj.environment.trim() : "") ||
_metaStr(ctx, ["environment", "env"], 32) ||
"";
return {
environment: _META_ENV_RE.test(rawEnv) ? rawEnv.toLowerCase() : "production",
runtime_name: _metaStr(ctx, ["runtime_name", "runtime"], 32),
runtime_version: _metaStr(ctx, ["runtime_version"], 32),
host_name: _metaStr(ctx, ["host_name", "hostname", "host"], 128),
release_version: _metaStr(ctx, ["release_version", "release", "app_version"], 64),
request_id: _metaStr(ctx, ["request_id", "requestId"], 128),
};
}
async function _ingestOneEvent( async function _ingestOneEvent(
client: PoolConnection, client: PoolConnection,
input: { ingestKeyId: string; projectId: string; event: IngestEventInput }, input: { ingestKeyId: string; projectId: string; event: IngestEventInput },
@@ -296,11 +334,14 @@ async function _ingestOneEvent(
throw new Error("incident_upsert_failed"); throw new Error("incident_upsert_failed");
} }
const _meta = extractOccurrenceMetadata(_ev, _context);
const [occHeader] = await client.execute<ResultSetHeader>( const [occHeader] = await client.execute<ResultSetHeader>(
`INSERT INTO er_incident_occurrences ( `INSERT INTO er_incident_occurrences (
project_id, incident_id, ingest_key_id, occurred_at, level_raw, severity, project_id, incident_id, ingest_key_id, occurred_at, level_raw, severity,
message, stack_trace, context_json, schema_version, environment message, stack_trace, context_json, schema_version, environment,
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'production')`, runtime_name, runtime_version, host_name, release_version, request_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[ [
input.projectId, input.projectId,
_incidentRow.id, _incidentRow.id,
@@ -312,6 +353,12 @@ async function _ingestOneEvent(
_stack, _stack,
_context === null ? null : JSON.stringify(_context), _context === null ? null : JSON.stringify(_context),
_ev.schema_version, _ev.schema_version,
_meta.environment,
_meta.runtime_name,
_meta.runtime_version,
_meta.host_name,
_meta.release_version,
_meta.request_id,
], ],
); );
const _occId = occHeader.insertId; const _occId = occHeader.insertId;
+4
View File
@@ -22,6 +22,10 @@ _run_sql_file "/migrations/error_reporting/20260322043000_create_error_reporting
_run_sql_file "/migrations/error_reporting/20260322044000_create_error_occurrences_and_states.up.sql" _run_sql_file "/migrations/error_reporting/20260322044000_create_error_occurrences_and_states.up.sql"
_run_sql_file "/migrations/error_reporting/20260322044500_add_ingest_idempotency.up.sql" _run_sql_file "/migrations/error_reporting/20260322044500_add_ingest_idempotency.up.sql"
_run_sql_file "/migrations/error_reporting/20260322045000_create_collectors_retention_and_audit.up.sql" _run_sql_file "/migrations/error_reporting/20260322045000_create_collectors_retention_and_audit.up.sql"
_run_sql_file "/migrations/error_reporting/20260402103000_add_occurred_at_for_stats.up.sql"
_run_sql_file "/migrations/error_reporting/20260402140000_ingest_key_rate_limits.up.sql"
_run_sql_file "/migrations/error_reporting/20260608150000_retire_wdmi_projects.up.sql"
_run_sql_file "/migrations/error_reporting/20260824120000_add_incidents_state_seen_idx.up.sql"
_run_sql_file "/migrations/admin/001_admin_users.sql" _run_sql_file "/migrations/admin/001_admin_users.sql"
_run_sql_file "/migrations/admin/002_admin_refresh_tokens.sql" _run_sql_file "/migrations/admin/002_admin_refresh_tokens.sql"
_run_sql_file "/migrations/admin/003_audit_logs.sql" _run_sql_file "/migrations/admin/003_audit_logs.sql"
+4
View File
@@ -40,6 +40,10 @@ _run "${_ROOT}/database/error_reporting/migrations/20260322043000_create_error_r
_run "${_ROOT}/database/error_reporting/migrations/20260322044000_create_error_occurrences_and_states.up.sql" _run "${_ROOT}/database/error_reporting/migrations/20260322044000_create_error_occurrences_and_states.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260322044500_add_ingest_idempotency.up.sql" _run "${_ROOT}/database/error_reporting/migrations/20260322044500_add_ingest_idempotency.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260322045000_create_collectors_retention_and_audit.up.sql" _run "${_ROOT}/database/error_reporting/migrations/20260322045000_create_collectors_retention_and_audit.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260402103000_add_occurred_at_for_stats.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260402140000_ingest_key_rate_limits.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260608150000_retire_wdmi_projects.up.sql"
_run "${_ROOT}/database/error_reporting/migrations/20260824120000_add_incidents_state_seen_idx.up.sql"
_run "${_ROOT}/db/migrations/001_admin_users.sql" _run "${_ROOT}/db/migrations/001_admin_users.sql"
_run "${_ROOT}/db/migrations/002_admin_refresh_tokens.sql" _run "${_ROOT}/db/migrations/002_admin_refresh_tokens.sql"
_run "${_ROOT}/db/migrations/003_audit_logs.sql" _run "${_ROOT}/db/migrations/003_audit_logs.sql"
@@ -0,0 +1,483 @@
#!/usr/bin/env python3
"""
Fleet audit — error reporting por slug (semanal).
Verifica se todos os slugs esperados estão a reportar eventos frescos para
errors.bitreport.pt. Para cada slug silencioso ou stale, cria uma issue de
correção no Paperclip.
Env vars lidos (ver /etc/paperclip/paperclip-fleet-error-audit.env):
PAPERCLIP_ERROR_API_KEY — chave leitura do hub
PAPERCLIP_FLEET_AUDIT_HUB_BASE — base URL do hub (default: https://errors.bitreport.pt)
PAPERCLIP_FLEET_AUDIT_EXPECTED_SLUGS — CSV de slugs esperados
PAPERCLIP_FLEET_AUDIT_MAX_AGE_HOURS — limiar de frescura (default: 168)
PAPERCLIP_FLEET_AUDIT_MAX_AGE_HOURS_OVERRIDES — CSV "slug=horas" por slug (opcional,
sobrepõe o limiar global para esse slug)
PAPERCLIP_FLEET_AUDIT_FETCH_LIMIT — rows a buscar (default: 2000)
PAPERCLIP_FLEET_AUDIT_MIN_ROWS — mínimo de rows antes de enforcement (default: 20)
PAPERCLIP_FLEET_AUDIT_PROJECT_ID — Paperclip project ID para issues de correção
PAPERCLIP_FLEET_AUDIT_ASSIGNEE_ID — Paperclip agent ID para assignar issues
PAPERCLIP_FLEET_AUDIT_PARENT_ID — (opcional) parent issue ID para sub-issues
PAPERCLIP_FLEET_AUDIT_ANCHOR_ISSUE_ID — (opcional) issue onde postar resumo
PAPERCLIP_API_URL — Paperclip API base
PAPERCLIP_API_KEY — Paperclip auth token
PAPERCLIP_COMPANY_ID — Paperclip company ID
PAPERCLIP_RUN_ID — run ID para audit trail
"""
from __future__ import annotations
import json
import os
import re
import subprocess
import sys
from collections import defaultdict
from datetime import datetime, timezone
from pathlib import Path
from typing import Any
from urllib import request as urllib_request
from urllib.error import HTTPError, URLError
# Marker convention used for one-off pipe-liveness verification events (e.g. sent by
# hand while investigating a "stale" finding, per BIT-30273/BIT-30527). These are real
# hub rows but not production traffic — counting them as "fresh" masks genuine staleness
# for as long as they remain the newest row for a slug. Excluded from freshness scoring.
# Accepts both the bracketed form (`[BIT-30527] ... smoke test`) and the bare form
# (`BIT-32663 smoke test`), matching the ingest noise policy `_BIT_ID_SMOKE_PROBE_RE`
# (BIT-32681). Anchored to start so a real error mentioning the phrase mid-sentence is not
# misclassified.
_SYNTHETIC_EVENT_RE = re.compile(r"^\[?BIT-\d+\]?\s+.*smoke test", re.IGNORECASE)
# ---------------------------------------------------------------------------
# Env helpers
# ---------------------------------------------------------------------------
def _load_env_file(path: str) -> None:
try:
lines = Path(path).read_text(encoding="utf-8").splitlines()
except OSError:
return
for line in lines:
line = line.strip()
if not line or line.startswith("#"):
continue
if "=" not in line:
continue
k, _, v = line.partition("=")
k = k.strip()
v = v.strip()
# strip inline comments
if "#" in v:
v = v[: v.index("#")].strip()
if k and k not in os.environ:
os.environ[k] = v
def _env(key: str, default: str = "") -> str:
return os.environ.get(key, default).strip()
def _env_int(key: str, default: int) -> int:
raw = _env(key)
if not raw:
return default
try:
return int(raw)
except ValueError:
return default
# ---------------------------------------------------------------------------
# HTTP helpers
# ---------------------------------------------------------------------------
def _get_json(url: str, headers: dict[str, str] | None = None) -> Any:
req = urllib_request.Request(url, headers=headers or {})
try:
with urllib_request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode())
except HTTPError as e:
body = e.read().decode(errors="replace")
raise RuntimeError(f"HTTP {e.code} {e.url}: {body[:300]}") from e
except URLError as e:
raise RuntimeError(f"URL error {url}: {e.reason}") from e
def _post_json(url: str, payload: dict[str, Any], headers: dict[str, str] | None = None) -> Any:
data = json.dumps(payload).encode()
hdrs = {"Content-Type": "application/json", **(headers or {})}
req = urllib_request.Request(url, data=data, headers=hdrs, method="POST")
try:
with urllib_request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode())
except HTTPError as e:
body = e.read().decode(errors="replace")
raise RuntimeError(f"HTTP {e.code} {e.url}: {body[:300]}") from e
except URLError as e:
raise RuntimeError(f"URL error {url}: {e.reason}") from e
def _patch_json(url: str, payload: dict[str, Any], headers: dict[str, str] | None = None) -> Any:
data = json.dumps(payload).encode()
hdrs = {"Content-Type": "application/json", **(headers or {})}
req = urllib_request.Request(url, data=data, headers=hdrs, method="PATCH")
try:
with urllib_request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode())
except HTTPError as e:
body = e.read().decode(errors="replace")
raise RuntimeError(f"HTTP {e.code} {e.url}: {body[:300]}") from e
except URLError as e:
raise RuntimeError(f"URL error {url}: {e.reason}") from e
# ---------------------------------------------------------------------------
# Hub query
# ---------------------------------------------------------------------------
def fetch_hub_rows(hub_base: str, api_key: str, limit: int) -> list[dict[str, Any]]:
url = (
f"{hub_base}/api/error-monitoring/recent-errors"
f"?limit={limit}&order=occurred_at_desc&status=open,investigating,resolved,ignored&api_key={api_key}"
)
# Use curl to avoid Cloudflare bot challenges on urllib
result = subprocess.run(
["curl", "-sf", "--max-time", "30", url],
capture_output=True, text=True,
)
if result.returncode != 0:
raise RuntimeError(f"curl failed (exit {result.returncode}): {result.stderr[:200]}")
try:
data = json.loads(result.stdout)
except json.JSONDecodeError as e:
raise RuntimeError(f"Invalid JSON from hub: {e} — body: {result.stdout[:200]}") from e
if not data.get("success"):
raise RuntimeError(f"Hub returned success=false: {data}")
return data.get("data", [])
def _parse_max_age_overrides(raw: str) -> dict[str, int]:
overrides: dict[str, int] = {}
for part in raw.split(","):
part = part.strip()
if not part or "=" not in part:
continue
slug, _, hours_raw = part.partition("=")
slug = slug.strip().lower()
try:
hours = int(hours_raw.strip())
except ValueError:
continue
if slug:
overrides[slug] = hours
return overrides
def analyse_rows(
rows: list[dict[str, Any]],
expected_slugs: list[str],
max_age_hours: int,
min_rows: int,
max_age_overrides: dict[str, int] | None = None,
) -> dict[str, Any]:
max_age_overrides = max_age_overrides or {}
now = datetime.now(timezone.utc)
# Aggregate per slug
by_slug: dict[str, list[datetime]] = defaultdict(list)
synthetic_skipped: dict[str, int] = defaultdict(int)
for row in rows:
slug = str(row.get("project_slug", "")).lower()
occurred_at_raw = row.get("occurred_at", "")
if not slug or not occurred_at_raw:
continue
message = str(row.get("message") or row.get("error_message") or "")
if _SYNTHETIC_EVENT_RE.match(message.strip()):
synthetic_skipped[slug] += 1
continue
try:
dt = datetime.fromisoformat(str(occurred_at_raw).replace("Z", "+00:00"))
by_slug[slug].append(dt)
except ValueError:
pass
total_rows = len(rows)
enforcement_active = total_rows >= min_rows
results: list[dict[str, Any]] = []
for slug in expected_slugs:
times = by_slug.get(slug, [])
slug_max_age = max_age_overrides.get(slug, max_age_hours)
if not times:
status = "silent"
hours_since = None
latest = None
else:
latest = max(times)
hours_since = (now - latest).total_seconds() / 3600
status = "stale" if hours_since > slug_max_age else "ok"
results.append(
{
"slug": slug,
"status": status,
"event_count": len(times),
"latest_occurred_at": latest.isoformat() if latest else None,
"hours_since_last_event": round(hours_since, 1) if hours_since is not None else None,
"max_age_hours": slug_max_age,
"synthetic_events_excluded": synthetic_skipped.get(slug, 0),
}
)
seen_slugs = sorted(by_slug.keys())
unexpected_slugs = [s for s in seen_slugs if s not in expected_slugs]
return {
"total_rows_fetched": total_rows,
"min_rows": min_rows,
"enforcement_active": enforcement_active,
"max_age_hours": max_age_hours,
"expected_slugs": expected_slugs,
"results": results,
"unexpected_slugs": unexpected_slugs,
"audited_at": now.isoformat(),
}
# ---------------------------------------------------------------------------
# Paperclip helpers
# ---------------------------------------------------------------------------
def paperclip_create_issue(
api_url: str,
api_key: str,
run_id: str,
company_id: str,
title: str,
description: str,
project_id: str,
assignee_id: str,
parent_id: str | None,
) -> dict[str, Any]:
payload: dict[str, Any] = {
"title": title,
"description": description,
"status": "todo",
"priority": "high",
"projectId": project_id,
"assigneeAgentId": assignee_id,
}
if parent_id:
payload["parentId"] = parent_id
headers = {
"Authorization": f"Bearer {api_key}",
"X-Paperclip-Run-Id": run_id,
}
return _post_json(f"{api_url}/api/companies/{company_id}/issues", payload, headers)
def paperclip_post_comment(
api_url: str,
api_key: str,
run_id: str,
issue_id: str,
body: str,
) -> dict[str, Any]:
headers = {
"Authorization": f"Bearer {api_key}",
"X-Paperclip-Run-Id": run_id,
}
return _post_json(
f"{api_url}/api/issues/{issue_id}/comments",
{"body": body},
headers,
)
def paperclip_update_issue(
api_url: str,
api_key: str,
run_id: str,
issue_id: str,
payload: dict[str, Any],
) -> dict[str, Any]:
headers = {
"Authorization": f"Bearer {api_key}",
"X-Paperclip-Run-Id": run_id,
}
return _patch_json(f"{api_url}/api/issues/{issue_id}", payload, headers)
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
def main() -> int:
# Load env files (automation.env first so fleet-audit.env can override)
_load_env_file("/etc/paperclip/automation.env")
_load_env_file("/etc/paperclip/paperclip-fleet-error-audit.env")
hub_base = _env("PAPERCLIP_FLEET_AUDIT_HUB_BASE", "https://errors.bitreport.pt").rstrip("/")
hub_api_key = _env("PAPERCLIP_ERROR_API_KEY")
expected_slugs_raw = _env("PAPERCLIP_FLEET_AUDIT_EXPECTED_SLUGS", "")
max_age_hours = _env_int("PAPERCLIP_FLEET_AUDIT_MAX_AGE_HOURS", 168)
max_age_overrides = _parse_max_age_overrides(_env("PAPERCLIP_FLEET_AUDIT_MAX_AGE_HOURS_OVERRIDES", ""))
fetch_limit = _env_int("PAPERCLIP_FLEET_AUDIT_FETCH_LIMIT", 2000)
min_rows = _env_int("PAPERCLIP_FLEET_AUDIT_MIN_ROWS", 20)
project_id = _env("PAPERCLIP_FLEET_AUDIT_PROJECT_ID")
assignee_id = _env("PAPERCLIP_FLEET_AUDIT_ASSIGNEE_ID")
parent_id = _env("PAPERCLIP_FLEET_AUDIT_PARENT_ID") or None
anchor_issue_id = _env("PAPERCLIP_FLEET_AUDIT_ANCHOR_ISSUE_ID") or None
api_url = _env("PAPERCLIP_API_URL", "http://127.0.0.1:3100")
api_key = _env("PAPERCLIP_API_KEY")
run_id = _env("PAPERCLIP_RUN_ID", "")
company_id = _env("PAPERCLIP_COMPANY_ID")
# Validation
if not hub_api_key:
print("ERROR: PAPERCLIP_ERROR_API_KEY is not set", file=sys.stderr)
return 1
expected_slugs = [s.strip().lower() for s in expected_slugs_raw.split(",") if s.strip()]
if not expected_slugs:
print("ERROR: PAPERCLIP_FLEET_AUDIT_EXPECTED_SLUGS is empty", file=sys.stderr)
return 1
print(f"Fleet audit starting — hub: {hub_base}")
print(f"Expected slugs: {expected_slugs}")
print(f"Max age: {max_age_hours}h, min rows: {min_rows}, fetch limit: {fetch_limit}")
if max_age_overrides:
print(f"Max age overrides: {max_age_overrides}")
# Fetch hub data
try:
rows = fetch_hub_rows(hub_base, hub_api_key, fetch_limit)
except RuntimeError as e:
print(f"ERROR fetching hub rows: {e}", file=sys.stderr)
return 1
print(f"Fetched {len(rows)} rows from hub")
# Analyse
report = analyse_rows(rows, expected_slugs, max_age_hours, min_rows, max_age_overrides)
print(json.dumps(report, indent=2, default=str))
# Determine problems
if not report["enforcement_active"]:
print(
f"\nEnforcement SKIPPED — only {report['total_rows_fetched']} rows "
f"(threshold: {min_rows}). Hub may be quiet; no correction issues created."
)
else:
problems = [r for r in report["results"] if r["status"] in ("silent", "stale")]
if problems:
print(f"\n{len(problems)} problem slug(s) found — creating correction issues")
else:
print("\nAll expected slugs are fresh — no correction issues needed")
problems = [r for r in report["results"] if r["status"] in ("silent", "stale")]
created_issues: list[dict[str, Any]] = []
if report["enforcement_active"] and problems and project_id and assignee_id and api_key and company_id:
for p in problems:
slug = p["slug"]
status = p["status"]
if status == "silent":
title = f"[fleet-audit] {slug} — sem eventos no hub (slug silencioso)"
desc = (
f"O slug `{slug}` não tem eventos registados em `{hub_base}`.\n\n"
f"Auditoria: {report['audited_at']}\n"
f"Total de rows no hub: {report['total_rows_fetched']}"
)
else:
hours = p["hours_since_last_event"]
latest = p["latest_occurred_at"]
slug_max_age = p["max_age_hours"]
title = f"[fleet-audit] {slug} — stale ({hours:.0f}h sem eventos)"
desc = (
f"O slug `{slug}` está stale: último evento há **{hours:.1f}h** "
f"(limiar: {slug_max_age}h).\n\n"
f"Último evento: `{latest}`\n"
f"Hub: `{hub_base}`\n"
f"Auditoria: {report['audited_at']}"
)
try:
issue = paperclip_create_issue(
api_url, api_key, run_id, company_id,
title, desc, project_id, assignee_id, parent_id,
)
issue_id = issue.get("id", "")
identifier = issue.get("identifier", "")
created_issues.append({"slug": slug, "issue_id": issue_id, "identifier": identifier})
print(f" Created correction issue {identifier} for slug '{slug}'")
except RuntimeError as e:
print(f" ERROR creating issue for slug '{slug}': {e}", file=sys.stderr)
# Build summary comment
lines = ["## Fleet Audit — Error Reporting por Slug", ""]
lines.append(f"**Auditado em:** {report['audited_at']}")
lines.append(f"**Hub:** {hub_base}")
lines.append(f"**Rows fetched:** {report['total_rows_fetched']} (min para enforcement: {min_rows})")
lines.append("")
if not report["enforcement_active"]:
lines.append("> **Enforcement inativo** — hub com poucos eventos, possível dia tranquilo.")
lines.append("")
lines.append("### Slugs esperados")
lines.append("")
for r in report["results"]:
slug = r["slug"]
st = r["status"]
if st == "ok":
hours = r["hours_since_last_event"]
icon = "✅"
detail = f"fresco — último evento há {hours:.1f}h"
elif st == "stale":
hours = r["hours_since_last_event"]
icon = "⚠️"
detail = f"stale — último evento há {hours:.1f}h (limiar: {r['max_age_hours']}h)"
else:
icon = "🔴"
detail = "silencioso — sem eventos"
lines.append(f"- {icon} **{slug}**: {detail}")
if report["unexpected_slugs"]:
lines.append("")
lines.append("### Slugs inesperados no hub (informação)")
for s in report["unexpected_slugs"]:
lines.append(f"- `{s}`")
if created_issues:
lines.append("")
lines.append("### Issues de correção criadas")
for ci in created_issues:
identifier = ci["identifier"]
issue_id = ci["issue_id"]
lines.append(f"- [{identifier}](/BIT/issues/{identifier}) — slug `{ci['slug']}`")
if not problems or not report["enforcement_active"]:
lines.append("")
lines.append("_Sem ações corretivas necessárias nesta execução._")
summary_comment = "\n".join(lines)
print("\n--- SUMMARY ---")
print(summary_comment)
# Post summary to anchor issue if configured
if anchor_issue_id and api_key:
try:
paperclip_post_comment(api_url, api_key, run_id, anchor_issue_id, summary_comment)
print(f"\nSummary posted to issue {anchor_issue_id}")
except RuntimeError as e:
print(f"WARNING: could not post summary comment: {e}", file=sys.stderr)
return 0
if __name__ == "__main__":
sys.exit(main())
+9 -9
View File
@@ -15,7 +15,7 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.2.0", "@eslint/eslintrc": "^3.2.0",
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"@types/react": "19.2.14", "@types/react": "19.2.14",
"@types/react-dom": "19.2.3", "@types/react-dom": "19.2.3",
"eslint": "^9.15.0", "eslint": "^9.15.0",
@@ -23,7 +23,7 @@
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
}, },
"node_modules/@emnapi/core": { "node_modules/@emnapi/core": {
@@ -982,13 +982,13 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.19.17", "version": "24.19.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
"integrity": "sha512-wGdMcf+vPYM6jikpS/qhg6WiqSV/OhG+jeeHT/KlVqxYfD40iYJf9/AE1uQxVWFvU7MipKRkRv8NSHiCGgPr8Q==", "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.21.0" "undici-types": ">=7.24.0 <7.24.7"
} }
}, },
"node_modules/@types/react": { "node_modules/@types/react": {
@@ -5311,9 +5311,9 @@
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "6.21.0", "version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
+2 -2
View File
@@ -17,7 +17,7 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.2.0", "@eslint/eslintrc": "^3.2.0",
"@types/node": "^22.9.0", "@types/node": "^24.0.0",
"@types/react": "19.2.14", "@types/react": "19.2.14",
"@types/react-dom": "19.2.3", "@types/react-dom": "19.2.3",
"eslint": "^9.15.0", "eslint": "^9.15.0",
@@ -25,6 +25,6 @@
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=24.22.1"
} }
} }