feat(selfhost): opt-in @sentry/node error tracking with boot/queue/review capture seams - #1547
Merged
Conversation
…view capture seams Reconciled onto current main (the batch's original #1468 sat on the diverged lane-refactor; re-applied the captures fresh to main's files). Modular opt-in via SENTRY_DSN — a complete no-op when unset; @sentry/node is dynamically imported so it never enters the Worker bundle. When on: boot crashes (uncaught/unhandled, flushed before exit), queue dead-letter on both backends, and degraded reviews tagged by repo/PR/SHA. beforeSend scrubs token/secret-like fields. 100% covered.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1547 +/- ##
==========================================
+ Coverage 95.36% 95.37% +0.01%
==========================================
Files 197 198 +1
Lines 21464 21514 +50
Branches 7759 7776 +17
==========================================
+ Hits 20470 20520 +50
Misses 416 416
Partials 578 578
🚀 New features to boost your workflow:
|
| release: env.SENTRY_RELEASE ?? env.GITTENSORY_VERSION, | ||
| tracesSampleRate: Number(env.SENTRY_TRACES_SAMPLE_RATE ?? "0"), | ||
| serverName: env.PUBLIC_API_ORIGIN, | ||
| beforeSend: (e) => scrubEvent(e), |
Contributor
There was a problem hiding this comment.
P2: Sentry beforeSend scrubber misses secret-bearing event fields
beforeSend only scrubs headers, contexts, and extra, missing URL query params, breadcrumbs, and error messages where secrets often appear.
Expand scrubEvent to recursively redact secrets across the entire Sentry event, including request.url, breadcrumbs, and exception values.
AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.
<file name="src/selfhost/sentry.ts">
<violation number="1" location="src/selfhost/sentry.ts:47">
<priority>P2</priority>
<title>Sentry beforeSend scrubber misses secret-bearing event fields</title>
<evidence>The scrubEvent function only redacts request.headers, contexts, and extra, leaving many Sentry event fields unscrubbed. Secrets in error messages (exception.values[].value), request URLs with query parameters (request.url, request.query_string), breadcrumbs, user context, and stack-trace local variables can leak to the configured Sentry endpoint.</evidence>
<recommendation>Expand scrubEvent to recursively redact secret-patterned keys across the entire Sentry event object, not just a whitelist of three fields. Alternatively, specifically target additional secret-bearing fields such as request.url, request.query_string, breadcrumbs, exception.values[].value, and user context. Consider using Sentry's built-in sendDefaultPii: false and server-side data scrubbing as defense-in-depth.</recommendation>
</violation>
</file>
This was referenced Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reconciles Sentry #1468 from the self-host batch onto current main. (The batch's original commit sat on top of the diverged lane-refactor, so cherry-pick wasn't clean — I re-applied the captures fresh to main's files.)
Modular opt-in via
SENTRY_DSN— a complete no-op when unset;@sentry/nodeis dynamically imported so it never enters the Worker bundle. When on: boot crashes (uncaught/unhandled, flushed before exit), queue dead-letter on both backends, and degraded reviews tagged by repo/PR/SHA.beforeSendscrubs token/secret-like fields. 100% line+branch coverage, 10 tests.First of the batch-reconciliation PRs (Sentry → dashboards → Discord → Redis → per-repo features).