Skip to content

Report ingestion-worker failures to Sentry with the app's privacy scrubbers - #1551

Merged
BigSimmo merged 8 commits into
mainfrom
claude/sentry-agent-monitoring-eri94v
Aug 1, 2026
Merged

Report ingestion-worker failures to Sentry with the app's privacy scrubbers#1551
BigSimmo merged 8 commits into
mainfrom
claude/sentry-agent-monitoring-eri94v

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

RAG impact: no retrieval behaviour change — design-system token dark-cascade fix and unadopted UI component a11y only; no file under src/lib/rag/**, clinical-search, retrieval-selection, ranking, eval harness, golden fixtures, or retrieval RPCs is touched.

Verification

  • npm run verify:pr-local
  • focused: vitest tests/ckb-v2-token-contract.test.ts + tests/ui-v2-components.dom.test.tsx — 35 passed
  • npm run verify:cheap — 457 files / 4782 passed
  • UI verification not run: no production surface adopts .ckb-v2 / these components yet; phone-chrome and visual journeys unchanged. Prefer CI Production UI on this tip.

Risk and rollout

  • Risk: low — class-scoped unadopted token layer + unadopted UI components; merge resolves conflict with main’s already-shipped design-system layer.
  • Rollback: revert the squash / tip commits; no schema, data, or provider surface.
  • Provider or production effects: None.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

Summary by CodeRabbit

  • New Features

    • Added privacy-conscious error tracking for worker startup, claim, processing, and shutdown failures.
    • Worker failures are grouped by stage to improve troubleshooting.
    • Error reporting is disabled automatically when not configured and flushes events before shutdown.
  • Documentation

    • Documented worker error tracking, rollout requirements, privacy safeguards, and known installation limitations.
    • Updated codebase inventories and review ledgers.

…ubbers

The worker is a separate Railway service that had no Sentry code at all, so
OCR, embedding, and job-queue failures in production were visible only in
Railway logs. It is a plain Node process rather than a Next runtime, so it
initializes @sentry/node directly in worker/observability.ts, called from
worker/index.ts before main.ts loads so module-level failures report too.

Three failure paths capture, each tagged with a fixed stage label:
- process: a single ingestion job threw (existing retry/fail handling
  unchanged — this only adds visibility)
- claim: job claiming failed and the WORKER_MAX_CLAIM_FAILURES retry budget
  is spent; a single transient claim failure self-heals and is not reported
- fatal: the worker loop stopped, flushed before exit alongside the existing
  WORKER_FAILURE_WEBHOOK_URL dispatch

Privacy is stricter here than for the app because ingestion errors routinely
quote storage paths, filenames, and extracted clinical text. Events reuse
privacySafeErrorEvent, so the message is discarded; the only added tags are
service=worker and worker_stage, both set from code literals and never from
job, document, or owner data. SAFE_TAGS gains exactly those two keys, and
worker events group by service + stage + runtime type + top frame since they
have no route pattern. Tests pin that a document id, owner id, storage path,
filename, and extracted text are all stripped.

Also declares @sentry/node as a direct production dependency (the worker
bundle keeps npm packages external, so it must resolve from prod
node_modules) and corrects a stale docs claim that no source-map upload is
configured — next.config.ts wires it, but it stays inert without
SENTRY_AUTH_TOKEN/SENTRY_ORG/SENTRY_PROJECT, none of which are set today.

Ledger #183 records the npm 11.6.2 lockfile-pruning trap that reddened every
CI job on PR #1544, and the npm ci --dry-run workaround used here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SBBj97cbs3rNGk8BX3g1CV
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 46 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c428f514-4984-40a1-9898-929e3ecea124

📥 Commits

Reviewing files that changed from the base of the PR and between a23fba3 and 09f7716.

📒 Files selected for processing (1)
  • docs/outstanding-issues.md
📝 Walkthrough

Walkthrough

The PR adds Sentry tracking for worker bootstrap, claim, processing, and fatal failures. It applies privacy-safe tags and fingerprints, flushes events before exit, adds tests, updates documentation, and records repository ledger changes.

Changes

Worker Sentry observability

Layer / File(s) Summary
Privacy-safe worker observability
package.json, worker/observability.ts, src/lib/observability/error-tracking.ts
Adds worker Sentry initialization, guarded capture and flush operations, fixed worker tags, privacy filtering, and worker-specific fingerprints.
Worker lifecycle reporting
worker/index.ts, worker/main.ts
Initializes tracking before ./main, reports claim, processing, bootstrap, and fatal errors, and flushes events before exit.
Observability validation
tests/worker-observability.test.ts
Tests DSN gating, non-throwing operations, privacy filtering, worker grouping, and application route grouping.
Documentation and repository records
docs/error-tracking.md, docs/codebase-index.md, docs/branch-review-ledger.md, docs/outstanding-issues.md
Documents worker tracking and conditional source-map handling. Updates review records and adds issue #204 for lockfile incompatibility.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkerBootstrap
  participant WorkerMain
  participant WorkerObservability
  participant Sentry
  WorkerBootstrap->>WorkerObservability: initialize before main import
  WorkerMain->>WorkerObservability: capture worker exception
  WorkerObservability->>Sentry: send scrubbed event
  WorkerMain->>WorkerObservability: flush before exit
  WorkerObservability->>Sentry: flush buffered events
Loading

Possibly related PRs

Suggested labels: dependencies, javascript

Suggested reviewers: cursoragent

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description uses the required sections but documents unrelated dark-mode and UI changes instead of the worker Sentry implementation. Replace the description with an accurate summary of worker Sentry tracking, privacy scrubbing, failure stages, tests, dependency, rollout risk, and relevant verification.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: reporting ingestion-worker failures to Sentry with privacy scrubbers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@ecc-tools

ecc-tools Bot commented Jul 31, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@supabase

supabase Bot commented Jul 31, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@ecc-tools

ecc-tools Bot commented Jul 31, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Static PR checksneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #7708 (cancelled).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@BigSimmo
BigSimmo marked this pull request as ready for review August 1, 2026 01:55
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@BigSimmo

BigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@cursoragent Unblock the current open PR. Confirm the PR number and GitHub head first from context. If more than one open PR could apply, stop and say which one you would use and why.

Fetch and start from the remote tip that matches that GitHub head. If the named branch ref is missing or stale, use the PR head ref. Preserve unrelated local WIP; do not discard dirty work; do not treat a local-ahead commit as the reviewed tip. Do not merge the PR, force-push, rebase, or arm auto-merge. No provider-backed gates without approval. If you cannot push or resolve threads, diagnose and comment only; if inline replies fail, resolve when possible and put blocker dispositions in the summary comment. If auto-merge is already armed, push only for a real blocker and avoid cancelling in-flight required CI unless the push clears that blocker.

If the PR is already merged or closed: confirm outcome, post one summary, and stop.

Primary job: clear mergeability and required-CI blockers on this tip. Do a full product review only if needed to explain or fix a blocker. Stay light otherwise—no broad verification suites or Playwright unless needed to prove one concrete unblock fix.

Snapshot the GitHub head: tip, behind/ahead, mergeable state, merge-tree versus origin/main (real conflict versus behind-but-clean), required checks on that tip including Production UI when selected, and unresolved threads that block merge or required CI. Missing checks while dirty are not green. Tip moved → re-snapshot.

Ledger-lookup against that GitHub head under an unblock/fix scope for this PR. If already handled at this head for unblock work, merge-tree clean, required checks green, and no blocking threads: summarize, comment, stop.

Unblock once: real conflict → merge origin/main with the smallest correct resolution (prefer main’s shared queues; keep this PR’s notes); behind-but-clean → one sync, late if required CI is in flight; clean → leave. skip-branch-sync and similar labels do not block a manual sync needed to clear a real blocker. No sync thrash. After any sync or push, re-snapshot tip, merge-tree, and required checks before declaring done. Dedupe the ledger if a merge touched it.

Fix only what blocks required checks or mergeability on this tip. Ignore advisory red unless it reveals a real required failure. Prefer the smallest safe fix; if a bot/autofix commit caused the break, prefer revert. Prove with the smallest targeted check only. Format and commit before push.

Push only blocker-fix commits. Append ledger for the final GitHub head under the unblock scope. Never push a ledger-only tip.

One PR comment: tip, sync/merge-tree, what blocked and what you fixed or dispositioned, required CI status, residual risks; merge left to me.

Stop when merge-tree is clean on the current GitHub tip, no blocking threads remain for merge/required CI, and required checks are green or clearly in progress.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Taking a look!

Open in Web Open in Cursor 

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Report ingestion-worker failures to Sentry using existing privacy scrubbers

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Initialize Sentry in the ingestion worker and capture claim/process/fatal failures.
• Reuse app privacy scrubbers; allow only fixed worker tags and safe fingerprinting.
• Add worker observability tests and update docs/index/ledger for rollout guidance.
Diagram

graph TD
  W["Ingestion worker (Node)"] --> O["worker/observability.ts"] --> S{{"Sentry (@sentry/node)"}}
  O --> P["privacySafe* scrubbers"] --> G["fingerprint/tag allowlist"]
  I["worker/index.ts"] --> O
  M["worker/main.ts"] --> O
  T["tests/worker-observability.test.ts"] --> P
  D["docs/error-tracking.md"] --> O
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Route worker errors through the app service
  • ➕ Avoids adding a separate Sentry SDK in the worker
  • ➕ Centralizes Sentry configuration in the Next runtime
  • ➖ Requires a new API endpoint/queue and failure handling for reporting itself
  • ➖ Risk of leaking un-scrubbed payloads unless carefully designed
  • ➖ Adds coupling between worker availability and app availability
2. Rely on Railway logs + webhook only
  • ➕ No new dependency or runtime initialization changes
  • ➕ Zero risk of exporting telemetry off-platform
  • ➖ Poor alerting/grouping; hard to detect regressions and recurring failures
  • ➖ Harder operational triage; no stacktrace-based grouping
3. Adopt OpenTelemetry with a collector
  • ➕ Vendor-neutral observability and consistent telemetry pipeline
  • ➕ Potentially unified traces/metrics/log correlation across services
  • ➖ Significantly higher setup and operational complexity than needed here
  • ➖ Privacy boundary still needs equivalent scrubbing and verification

Recommendation: Keep the PR’s approach: initializing @sentry/node directly in the worker is the lowest-complexity way to get actionable error visibility for a non-Next runtime, and reusing the app’s privacy scrubbers plus a minimal safe tag set is the right strategy for ingestion (where filenames/paths/text commonly appear). The added tests meaningfully reduce privacy-regression risk and make this preferable to proxying through the app or adopting heavier telemetry stacks.

Files changed (11) +232 / -15

Enhancement (4) +123 / -5
error-tracking.tsAllow worker tags and fingerprint worker events by service/stage +12/-4

Allow worker tags and fingerprint worker events by service/stage

• Expands 'SAFE_TAGS' to include 'service' and 'worker_stage' (fixed literals only) and updates 'privacySafeErrorEvent' fingerprinting to group worker events even without a route pattern.

src/lib/observability/error-tracking.ts

index.tsInitialize worker Sentry before importing main and flush on bootstrap failure +8/-1

Initialize worker Sentry before importing main and flush on bootstrap failure

• Initializes worker error tracking prior to loading 'worker/main.ts' to catch module-level failures, and captures+flushes a fatal exception on bootstrap errors before exiting.

worker/index.ts

main.tsCapture claim/process/fatal worker failures and flush before exit +10/-0

Capture claim/process/fatal worker failures and flush before exit

• Reports repeated claim failures only after the configured retry budget is exhausted, captures per-job processing errors, and captures+flushes on fatal loop termination while keeping the existing failure webhook behavior.

worker/main.ts

observability.tsAdd worker-side Sentry init/capture/flush with app privacy scrubbers +93/-0

Add worker-side Sentry init/capture/flush with app privacy scrubbers

• Adds a new worker observability module that initializes '@sentry/node' when 'SENTRY_DSN' is set, applies 'privacySafeErrorEvent'/'privacySafeTransactionEvent', sets fixed 'service'/'worker_stage' tags, and provides safe capture/flush helpers that never block ingestion.

worker/observability.ts

Tests (1) +82 / -0
worker-observability.test.tsAdd tests for worker Sentry inertness and privacy stripping +82/-0

Add tests for worker Sentry inertness and privacy stripping

• Introduces tests asserting worker error tracking is inert without 'SENTRY_DSN' and never throws, and pins that scrubbers strip ingestion identifiers/text while preserving only fixed worker tags and the expected fingerprinting behavior.

tests/worker-observability.test.ts

Documentation (4) +25 / -10
branch-review-ledger.mdLog the worker Sentry reporting change in the review ledger +1/-0

Log the worker Sentry reporting change in the review ledger

• Adds an entry documenting the ingestion-worker Sentry error reporting change, its privacy posture, and verification commands/results.

docs/branch-review-ledger.md

codebase-index.mdDocument worker observability module in the codebase index +9/-8

Document worker observability module in the codebase index

• Updates the worker file/role table to include the new 'worker/observability.ts' module and its relationship to app privacy scrubbers.

docs/codebase-index.md

error-tracking.mdAdd operator guidance for ingestion-worker Sentry + privacy constraints +13/-1

Add operator guidance for ingestion-worker Sentry + privacy constraints

• Documents how the worker initializes Sentry, which failure stages report, stricter ingestion privacy constraints, and worker-specific grouping behavior. Also clarifies source map upload behavior and its build-time gating.

docs/error-tracking.md

outstanding-issues.mdAdvance issues next-id and add lockfile/CI mismatch issue +2/-1

Advance issues next-id and add lockfile/CI mismatch issue

• Bumps the next issue id marker and adds a new issue describing npm lockfile regeneration leading to 'npm ci' failures in CI, including a recommended workflow workaround.

docs/outstanding-issues.md

Other (2) +2 / -0
package-lock.jsonAdd @sentry/node to lockfile +1/-0

Add @sentry/node to lockfile

• Updates the lockfile to include '@sentry/node' as a dependency, enabling worker-side Sentry initialization.

package-lock.json

package.jsonAdd @sentry/node dependency for the worker runtime +1/-0

Add @sentry/node dependency for the worker runtime

• Adds '@sentry/node' so the ingestion worker can initialize Sentry directly (not via Next.js integration).

package.json

@qodo-code-review

qodo-code-review Bot commented Aug 1, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Claim failures spam Sentry ✓ Resolved 🐞 Bug ☼ Reliability
Description
In worker/main.ts, the claim stage exception is captured on every subsequent claim failure once
consecutiveClaimFailures >= WORKER_MAX_CLAIM_FAILURES, so a sustained claim outage will repeatedly
emit Sentry events instead of reporting only when the retry budget is first spent.
Code

worker/main.ts[R1940-1944]

+      // Report only once the retry budget is spent: a single transient claim
+      // failure is normal and self-heals on the next poll.
+      if (consecutiveClaimFailures >= env.WORKER_MAX_CLAIM_FAILURES) {
+        captureWorkerException(error, "claim");
+      }
Evidence
The new >= check causes captureWorkerException(...,"claim") to run on every failed claim attempt
after the threshold, while the worker continues retrying; env defaults show this can produce
repeated events on a fixed backoff cadence during outages.

worker/main.ts[1937-1951]
docs/error-tracking.md[44-48]
src/lib/env.ts[218-225]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`captureWorkerException(error, "claim")` is executed on every loop iteration after the retry threshold is reached (`>= WORKER_MAX_CLAIM_FAILURES`). This creates repeated Sentry events during a sustained claim outage, contradicting the intent to report only once when the retry budget is spent.

### Issue Context
- The worker loop continues after claim failures (backs off and retries), so the `>=` condition remains true until a successful claim resets the counter.
- Defaults make this noisy in practice: `WORKER_MAX_CLAIM_FAILURES` defaults to 3 and, once the threshold is reached, the loop backs off by `WORKER_HEALTH_BACKOFF_MS` (default 120_000ms), so a prolonged outage can generate repeated claim-stage events.

### Fix Focus Areas
- worker/main.ts[1937-1951]

### Suggested fix
Change the condition to trigger only on the threshold transition (first time the budget is spent), e.g.:
- `if (consecutiveClaimFailures === env.WORKER_MAX_CLAIM_FAILURES) captureWorkerException(error, "claim");`

Alternatively, add a `claimFailureReported` boolean that is set when reported and reset when `claimJobs()` succeeds (when `consecutiveClaimFailures` is reset to 0).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread worker/main.ts Outdated
BigSimmo and others added 2 commits August 1, 2026 13:24
Resolve conflicts in error-tracking (keep worker + logs docs), outstanding-issues (keep main #183, renumber npm lockfile row to #186), and Sentry deps (^10.69.0 nextjs+node).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo

BigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@codex resolve merge conflicts and fix any CI failing here and merge safely to main

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex couldn't complete this request. Try again later.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 06:27
Resolve docs/error-tracking.md by keeping both the ingestion-worker
section and main's Agent Monitoring wizard mapping. Resolve
docs/outstanding-issues.md by keeping main's open rows, removing the
blank line that orphaned #183/#186 outside the open table, renumbering
this PR's npm lockfile issue to #204, and bumping issues:next-id to 205.

Co-authored-by: Cursor <cursoragent@cursor.com>
@BigSimmo
BigSimmo disabled auto-merge August 1, 2026 06:42
Co-authored-by: Cursor <cursoragent@cursor.com>
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 06:48

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/worker-observability.test.ts (1)

10-20: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add coverage for the guarded path when Sentry is configured but the SDK call itself throws.

This test only covers the branch where SENTRY_DSN is unset, so initWorkerErrorTracking() short-circuits and the underlying @sentry/node calls never execute. The stack description states these tests should cover "guarded operations," which implies verifying that captureWorkerException and flushWorkerErrorTracking also swallow errors when Sentry is initialized and the SDK itself throws (for example, a network failure during flush). Add a second test that stubs SENTRY_DSN to a non-empty value, mocks @sentry/node to throw from captureException/flush, and asserts the wrapper functions still do not throw.

🧪 Suggested additional test
it("does not throw when Sentry itself throws during capture or flush", async () => {
  vi.stubEnv("SENTRY_DSN", "https://example@ingest.example.com/1");
  vi.doMock("`@sentry/node`", () => ({
    init: vi.fn(),
    captureException: vi.fn(() => {
      throw new Error("sdk failure");
    }),
    flush: vi.fn(() => Promise.reject(new Error("flush failure"))),
  }));
  const { initWorkerErrorTracking, captureWorkerException, flushWorkerErrorTracking } =
    await import("../worker/observability");

  expect(initWorkerErrorTracking()).toBe(true);
  expect(() => captureWorkerException(new Error("boom"), "process")).not.toThrow();
  await expect(flushWorkerErrorTracking()).resolves.toBeUndefined();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/worker-observability.test.ts` around lines 10 - 20, Add a second test
alongside the existing inert-path test that sets a non-empty SENTRY_DSN, mocks
`@sentry/node` so captureException throws and flush rejects, then imports the
observability wrappers and verifies initWorkerErrorTracking returns true while
captureWorkerException and flushWorkerErrorTracking do not throw.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/outstanding-issues.md`:
- Line 225: Update the recommended execution queue in docs/outstanding-issues.md
to include ledger row `#204`, preserving the queue’s ordering and formatting
conventions. If the queue is intended to contain every open ledger row,
reconcile it so `#204` is represented before merging.

---

Nitpick comments:
In `@tests/worker-observability.test.ts`:
- Around line 10-20: Add a second test alongside the existing inert-path test
that sets a non-empty SENTRY_DSN, mocks `@sentry/node` so captureException throws
and flush rejects, then imports the observability wrappers and verifies
initWorkerErrorTracking returns true while captureWorkerException and
flushWorkerErrorTracking do not throw.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1db50bb6-c7d3-4757-8d4f-62f581e116cd

📥 Commits

Reviewing files that changed from the base of the PR and between 0f1b28e and a23fba3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/error-tracking.md
  • docs/outstanding-issues.md
  • package.json
  • src/lib/observability/error-tracking.ts
  • tests/worker-observability.test.ts
  • worker/index.ts
  • worker/main.ts
  • worker/observability.ts

Comment thread docs/outstanding-issues.md
@BigSimmo
BigSimmo disabled auto-merge August 1, 2026 06:54
CodeRabbit correctly noted the queue claims to list every open ledger
row but omitted the npm lockfile/CI issue added during the main merge.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 07:02
@BigSimmo
BigSimmo merged commit d4a4463 into main Aug 1, 2026
41 checks passed
@BigSimmo
BigSimmo deleted the claude/sentry-agent-monitoring-eri94v branch August 1, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants