Skip to content

feat(selfhost): opt-in @sentry/node error tracking with boot/queue/review capture seams - #1547

Merged
JSONbored merged 1 commit into
mainfrom
chore/reconcile-sentry
Jun 26, 2026
Merged

feat(selfhost): opt-in @sentry/node error tracking with boot/queue/review capture seams#1547
JSONbored merged 1 commit into
mainfrom
chore/reconcile-sentry

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

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/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% line+branch coverage, 10 tests.

First of the batch-reconciliation PRs (Sentry → dashboards → Discord → Redis → per-repo features).

…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.
@dosubot dosubot Bot added the size:XL label Jun 26, 2026
@JSONbored JSONbored self-assigned this Jun 26, 2026
@JSONbored JSONbored added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jun 26, 2026
@JSONbored JSONbored moved this from Todo to In progress in gittensory - v1 roadmap Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.37%. Comparing base (8844796) to head (f8e665b).
✅ All tests successful. No failed tests found.

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              
Files with missing lines Coverage Δ
src/queue/processors.ts 87.43% <100.00%> (+<0.01%) ⬆️
src/selfhost/sentry.ts 100.00% <100.00%> (ø)
src/selfhost/sqlite-queue.ts 97.33% <100.00%> (+0.19%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/selfhost/sentry.ts
release: env.SENTRY_RELEASE ?? env.GITTENSORY_VERSION,
tracesSampleRate: Number(env.SENTRY_TRACES_SAMPLE_RATE ?? "0"),
serverName: env.PUBLIC_API_ORIGIN,
beforeSend: (e) => scrubEvent(e),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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&apos;s built-in sendDefaultPii: false and server-side data scrubbing as defense-in-depth.</recommendation>
</violation>
</file>

@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jun 26, 2026
@JSONbored
JSONbored merged commit 9de2106 into main Jun 26, 2026
18 of 19 checks passed
@JSONbored
JSONbored deleted the chore/reconcile-sentry branch June 26, 2026 21:27
@github-project-automation github-project-automation Bot moved this from In progress to Done in gittensory - v1 roadmap Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. pr:flagged PR flagged for review by security analysis.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(selfhost): observability hooks — @sentry/node error tracking module + boot/queue/review capture seams

1 participant