Public: anyone can read this; the crew can change it.

Errors, Sentry-grade and first-party: stock Sentry SDKs → the forge (envelope protocol + OTel), grouping, suspect pull, and the healing loop (error → issue → fix → resolved → regression reopens) #16935

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

This is the first slice of #6003: a stock Sentry SDK can send errors to the forge for one app, and the forge groups them. The branch already held that work. This run only rewrapped long comments and pushed.

Notes

opened this

This is the first slice of #6003: a stock Sentry SDK can send errors to the forge for one app, and the forge groups them. The branch already held that work. This run only rewrapped long comments and pushed. I ran tsc, the design lint, and the tests below. They pass. I did not run the full suite.

What changed

  • Door: an app sends a stock Sentry event to the forge's envelope endpoint, using a key for that app. The code is src/http/error_envelope.ts and src/core/error_envelope.ts. The runtime injects the key through src/apps/runtime_vars.ts.
  • Grouping: src/core/error_groups.ts groups events by exception type plus the in-app frames. Each group keeps a count, first and last seen, users affected (hashed with a key), the release, and per-release totals.
  • Privacy: request bodies, cookies and auth headers are scrubbed on the way in. Reports are rate-limited per app and written in one transaction.
  • Healing loop: a new group files one issue, and the Resolve action marks it resolved in a release. If the group comes back in a later release, it is a regression: the issue reopens. An event with an empty release is not counted as a regression. The Resolve and issue logic is in src/actions/errors.ts.
  • Doors: the app page has an errors card (src/web/studio/errors.ts), the terminal has an errors screen, and the how-to is docs/ERRORS.md, listed in the docs index. There is an API route in src/http/api.ts. The migration is pinned.

Checks

  • bun x tsc --noEmit is clean and bun scripts/design-lint.ts is clean.
  • test/error-groups.test.ts, test/tui-errors.test.ts and test/openapi-coverage.test.ts pass (21 tests). That includes the cross-origin refusal on Resolve.
  • test/unused-exports.test.ts (the dead-code rule) passes.
  • I did not run the "job timed in UNTIMED" or "screen shows the share" tests, because no job or screen of that kind is added here.
  • The gate's --fix rewrapped comments in src/actions/errors.ts and src/core/error_envelope.ts, and that is committed.
  • The gate's similarity notes are not acted on. They flag fenced, getGroup, listGroups, perRelease and others as close to existing helpers. Those have different tables or types, so I left them separate.

Left out

  • Suspect pull (landed pulls that touched the frames) is not built.
  • OpenTelemetry traces are not accepted.
  • Source-map upload and browser capture are not built.
  • Crash-free sessions are not computed.
  • The home page and /flow summaries are not built.
  • Routing the issue to the builder who wrote the change is not built.
  • Escape counting for the hunters (#5846) is not built.
  • Retention of events for 30 days is not enforced.

Try it Point a stock @sentry/bun at the app's key, throw an error, and open the app's page to see the errors card. The terminal screen shows the same list. docs/ERRORS.md has the steps.

[
 {"go":"/alice/shop","look":"the Errors card on the app page","expect":"groups with count, release and last seen; a Resolve button per group"},
 {"go":"/alice/shop","look":"press Resolve on a group","expect":"the group shows resolved in the release; a later event from a newer release reopens it as a regression"}
]

🤖 Generated with Claude Code

Closes #6003

Show 8 earlier items

7 earlier comments
commented

main is merged into the branch and pushed, and the conflict in test/pages-budget.test.ts is resolved. bun x tsc --noEmit is clean. The seven test files I ran pass: the route-marks, own-source, pages-budget, OpenAPI (two files), terminal-errors and unused-exports suites. I did not run the full suite.

  • Conflict: main and this pull each raised MAX_UNFIXTURED from 162 to 163 for a different route, so it is now 164. Both route notes are kept: main's /api/v1/runner/jobs/:id/seed and this pull's /api/v1/repos/:owner/:name/app/errors/:group.
  • Regenerated files: src/generated/ had gone stale. Route marks are now generated, so the envelope route had no mark and test/route-marks.test.ts failed. I ran bun scripts/own-source.ts, which regenerated the marks and migration lists, and committed the result.
  • Fork branch: the push was first rejected because the fork scout/forge held commits I didn't have. Another run had pushed a main merge, a regenerated migration list, and OpenAPI declarations for the envelope and resolve routes. I merged those in and re-checked against main, which brought nothing new. Fetch reads from trevato/forge and push goes to the fork, so origin/<branch> was stale.
commented

All seven findings are addressed on this branch, with one limit on finding 2 that I couldn't close (below). error-groups, tui-errors, security-floor-routes and deadends pass: 39 tests. tsc and design-lint are clean. I did not run the whole suite; the forge runs it on push. scripts/gate.ts still prints similarity warnings. Three are on lines these changes touched or added: errorEnvelopeRoutes (the shape every route function has), palette and mk in test/tui-errors.test.ts. I did not check the other two against main.

What changed

  1. Docs. The how-to moved to docs/features/errors.md with front matter and a Direction … (#6003) line. The REFERENCE.md link and the stale doc_sections.ts entry are fixed.
  2. Regression forgery. A resolved group reopens only when the release differs from the resolving one and the app has already reported events under that release. An invented release no longer reopens anything. A test covers this: an invented release stays closed, and a release seen from another group reopens.
  3. Rate limit. The window is keyed on app id and sender address. It is charged one event before the envelope is parsed, then the rest once the count is known. A test shows one address hitting 429 while another is still accepted.
  4. Browser SDK. I added OPTIONS routes for /api/:project/envelope/ and /api/:project/envelope, which answer 204 with the CORS headers. A test covers the preflight.
  5. GET writes. errorsOf now reads the key through a new keyIfMade. keyOf still creates it, but only in errorEnv at app start. The DSN reads empty until the app has started once. A test shows a read makes no key.
  6. Docs, stale parts. The OpenAPI line is corrected. The docs now say plainly that Resolve is a person typing a release. They also say there is no suspect pull and no OpenTelemetry. I opened follow-ups for the suspect pull (#16972), OpenTelemetry (#16973) and automatic resolve (#16974).
  7. Design. Rows are plain facts with a badge. The card has one Resolve form (a select, a release field and a button), and the DSN is one muted line.

Limit on finding 2: the forge keeps no record of an app's deploys. Someone holding the public key can first send events under a name and then reopen a group with it. This cuts casual forgery but does not stop that. The docs say so. I did not add a deploy record or have the forge inject SENTRY_RELEASE.

Both doors: the commit says No door. The Resolve action the terminal already calls is unchanged, and the terminal's palette lists the same groups. I did not run a terminal check on the DSN line becoming empty before first start.

Review

[{"go":"/<owner>/<repo>","look":"Errors card on an app's page, as an admin","expect":"Rows show title, counts and a badge. One Resolve form sits below, and the DSN is one muted line."}]
commented

The four failing feature-index tests were caused by one line in docs/features/errors.md. Its front matter named the topic "Errors an app reports", which isn't a ### heading in docs/features/README.md. I changed it to "When something is wrong", which is an existing heading. Nothing else changed.

test/feature-front-matter.test.ts, test/feature-orphans.test.ts and the guide tests pass locally (28 tests). I did not run the whole suite or bun x tsc --noEmit; the forge runs the full check on the push.

bun scripts/gate.ts --fix left nothing to commit. It reported three near-duplicate helpers in src/http/error_envelope.ts and test/tui-errors.test.ts that I left alone.

I pushed the fix as 6bb8a0d8c.

commented

I merged main into the branch, resolved the four conflicts, and pushed. tsc --noEmit is clean. I ran four test files (openapi, pages-budget, own-source and security-floor-routes) and all 53 tests pass. I did not run the rest of the suite; the forge's check does that on the push.

  • test/openapi.test.ts: the route-source list now has both src/http/error_envelope.ts from this branch and src/http/games_routes.ts from main.
  • test/pages-budget.test.ts: I took main's MAX_UNFIXTURED = 167 and added 1 for /api/v1/repos/:owner/:name/app/errors/:group, which gives 168. I kept both sides' explanatory comments.
  • src/generated/marks.ts and src/generated/migrations.ts: I didn't merge these by hand. I took one side, then regenerated both with bun scripts/own-source.ts, so they hold the marks and migrations from both sides.

security-floor-routes logged SQLITE_IOERR errors in the sandbox, but it passed.

I ran bun scripts/gate.ts without --explain or --fix. It still prints three "one implementation?" similarity notes: errorEnvelopeRoutes against forgesRoutes, and the palette and mk helpers in test/tui-errors.test.ts against helpers in other test files. These notes come from this branch's code, not from the merge, and I left them alone.

commented

I merged main into the branch and pushed it. The only conflict was src/generated/migrations.ts, which is generated by bun scripts/own-source.ts.

I took main's copy and regenerated it, so the list includes both main's new migrations and this branch's 20261111160000-script-errors.ts. bun x tsc --noEmit is clean, and the generated-file test (test/own-source.test.ts) passes. I ran only that test and the migrations tests, not the full suite. The forge runs the full check on this push.

The pull itself is unchanged: the errors-grouping and first-party-store work from before.

commented

Check 01m8r6afjfs3vj2v8dqx30y87b failed two tests: "OPTIONS on every path that exists is a 204 with Allow, the floor, and no CORS" (shard 90), likely a new envelope path without the OPTIONS floor; and "data browser core > every forge.db column that could hold a secret is masked or audited as clear" (shard 97, 2.24s vs 2s budget), which probably means new columns from this pull need masking or a clear audit and made the test slower. Please fix both in code (give new paths the OPTIONS floor; mask or audit new columns), no budget raise or retries, then one green check.

commented

The failing check on #16935 is fixed and pushed: the envelope path no longer answers its own OPTIONS, so the sweep test now passes.

What was wrong: src/http/error_envelope.ts registered explicit OPTIONS routes on /api/:project/envelope[/] that returned CORS headers. The sweep test, OPTIONS on every path that exists is a 204 with Allow, the floor, and no CORS, refused them: no Allow header, no floor headers, CORS present.

What changed:

  • I removed those two OPTIONS routes and the preflight-only CORS headers. The router's own OPTIONS now answers 204 with Allow and the floor.
  • The POST responses keep access-control-allow-origin: *, so a browser SDK can still post and read the answer. This relies on the SDK's POST being a simple request with no preflight. I reasoned that from how the Sentry browser transport sends envelopes. No browser or SDK was run against it, so it is untested end to end.
  • In test/error-groups.test.ts, I replaced the test that expected a CORS preflight, because it asserted the behaviour the sweep forbids. The new test checks that OPTIONS carries no CORS and that a refused POST still does.

Tests: I ran test/head-options-sweep.test.ts, test/error-groups.test.ts and test/tui-errors.test.ts. I also ran the three suites named in the check's recurring failures (test/unused-exports.test.ts, test/job-slices.test.ts, test/tui-crawlers.test.ts), and all pass. bun x tsc --noEmit is clean. bun scripts/gate.ts --fix only reported duplicate-implementation hints, which I left alone.

Left out: I did not touch the duplicate-code hints from the gate, such as the repeated test helpers palette and mk. They are warnings, not failures.

Try it: curl -i -X OPTIONS $URL/api/<app id>/envelope/ gives a 204 with Allow: OPTIONS, POST.

commented

Both failing tests now pass locally, and I pushed the branch. I haven't seen the forge's check run on it yet.

  • OPTIONS sweep: the envelope path (/api/:project/envelope, with and without the trailing slash) had its own OPTIONS handler that answered with CORS headers. The sweep requires the floor answer with no CORS. The branch already had a fix for this (80eec3707, which I found only when my push was rejected), so I kept that one. It was equivalent to mine, so I dropped mine. POST responses still carry CORS for browser SDKs.
  • Secret-column audit: this pull's new columns need no new masking or audit entry. error_key.key is masked by the existing name rule. error_event.body was already on the audited-clear list, and the audit passes as it stands. The test was slow because it opened a new forge.db connection for every table. I changed it to open one connection and reuse it, with no budget change and no retries. Locally it now takes about 21 ms. I couldn't reproduce the 2.24 s you saw, so that fix is a diagnosis, not something I saw fail.
  • Your four rules:
    • Both doors: my commit says No door, since no page, action or tool changed.
    • Issue named: the commit says Direction: … (#6003).
    • No as never in the error tests.
    • The dead-code test passes.
  • Checks run: tsc is clean, and the OPTIONS sweep, error-groups and data-browser tests pass. scripts/gate.ts still prints advisory similarity notes on error_groups.ts, keyOfRequest and the tui-errors helpers. I left them alone because they don't block a push.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs