Skip to content

fix(sentry): suppress recoverable errors and fix grooming-error stringification#919

Merged
pedramamini merged 1 commit intorcfrom
fix/sentry-rc-noise
Apr 28, 2026
Merged

fix(sentry): suppress recoverable errors and fix grooming-error stringification#919
pedramamini merged 1 commit intorcfrom
fix/sentry-rc-noise

Conversation

@pedramamini
Copy link
Copy Markdown
Collaborator

@pedramamini pedramamini commented Apr 28, 2026

Summary

Cleans up four sources of high-volume Sentry noise observed on the rc channel where the bug and fix were obvious:

  • Worktree ENOENT noise (git.ts): scanWorktreeDirectory and watchWorktreeDirectory now skip captureException when the parent path doesn't exist. ENOENT is expected when the user moves/deletes a worktree directory — the renderer already handles the failure gracefully. Fixes MAESTRO-J5, MAESTRO-J6, MAESTRO-J7 (J7 alone was at 273 events/escalating).
  • Cue DB pre-init / shutdown race (cue-db.ts): safeRecordCueEvent / safeUpdateCueEventStatus now early-return when the DB handle is null instead of throwing through a captured catch. Both wrappers are documented as non-fatal. Fixes MAESTRO-JX.
  • Shell PATH probe timeouts (path-prober.ts): getExpandedEnvWithShell skips Sentry capture for the known recoverable cases (timeout / non-zero shell exit). Callers already fall back to the base expanded env. Fixes MAESTRO-J8.
  • Grooming error stringification (context-groomer.ts): agent-error events emit an AgentError plain object, so String(error) was producing the literal text [object Object] in Sentry titles. Now extracts .message when the value is object-shaped. Fixes MAESTRO-JB, MAESTRO-K7.

All four changes are scoped — they only suppress reporting / fix message formatting for known-recoverable paths; runtime behavior is unchanged. All issues above were tagged channel: rc in Sentry and verified against the current code.

Test plan

  • npm run lint (TypeScript multi-config) — clean
  • npm run lint:eslint on touched files — clean
  • vitest run for cue-db, cue-db-integration, cue-run-manager, context-groomer, git ipc handler, path-prober.shell-path — all pass (302 tests)
  • Confirm Sentry issue volumes drop on the next RC release once it ships

Summary by CodeRabbit

  • Bug Fixes
    • Improved error reporting accuracy by filtering routine and expected errors from monitoring systems, reducing unnecessary alerts
    • Fixed error message formatting that displayed generic placeholders instead of actual error details
    • Enhanced stability by adding initialization checks before database operations, ensuring graceful handling during incomplete startup states
    • Better error logging for operations encountering unavailable resources

…gification

Cleans up four sources of high-volume Sentry noise observed on the rc channel:

- git.ts scanWorktreeDirectory / watchWorktreeDirectory now skip
  captureException for ENOENT, which is expected when a configured
  worktree-parent path has been moved or deleted (Fixes MAESTRO-J5,
  MAESTRO-J6, MAESTRO-J7).

- cue-db.ts safeRecordCueEvent / safeUpdateCueEventStatus early-return when
  the DB handle is null, instead of throwing through a captured catch.
  This race fires during shutdown and pre-init and is already non-fatal
  (Fixes MAESTRO-JX).

- path-prober.ts getExpandedEnvWithShell skips captureException for the
  known recoverable shell PATH probe failures (timeout, non-zero shell
  exit). Callers already fall back to the base env (Fixes MAESTRO-J8).

- context-groomer.ts onError now extracts .message from AgentError plain
  objects rather than relying on String(error), which was producing
  "Grooming error: [object Object]" in Sentry (Fixes MAESTRO-JB,
  MAESTRO-K7).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b98d60fa-c3a0-4d9f-ab51-aac7c4a2f2b8

📥 Commits

Reviewing files that changed from the base of the PR and between b2c34b0 and b4ba80d.

📒 Files selected for processing (4)
  • src/main/agents/path-prober.ts
  • src/main/cue/cue-db.ts
  • src/main/ipc/handlers/git.ts
  • src/main/utils/context-groomer.ts

📝 Walkthrough

Walkthrough

This PR refines error handling and observability across four modules by conditionally reporting errors to Sentry. Expected errors—such as shell timeouts, non-zero exit codes, missing files (ENOENT), and database initialization gaps—are now logged but excluded from Sentry reporting, reducing noise while maintaining observability.

Changes

Cohort / File(s) Summary
Conditional Sentry Reporting
src/main/agents/path-prober.ts, src/main/ipc/handlers/git.ts
Made exception reporting conditional by suppressing known/expected error patterns: path-prober skips timeout and shell-exit failures; git handlers skip ENOENT errors. Errors are still logged; only Sentry capture is avoided.
Database Initialization Guards
src/main/cue/cue-db.ts
Added early null checks for db in safeRecordCueEvent and safeUpdateCueEventStatus, logging warnings and exiting before any database operation or Sentry reporting.
Error Message Extraction
src/main/utils/context-groomer.ts
Fixed error message construction in onError to correctly extract message property from plain objects in agent-error events, preventing [object Object] from appearing in logs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

ready to merge

Poem

🐰 Hop! Skip! Filter the noise,
Expected errors? No Sentry poise.
We log them all with care and grace,
But spare the warnings' virtual space!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing Sentry error reporting by suppressing recoverable errors and fixing error stringification in grooming.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sentry-rc-noise

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR suppresses high-volume Sentry noise from four known-recoverable paths: ENOENT in worktree directory scanning/watching, null-DB early returns in Cue safe wrappers, expected shell PATH probe failures, and fixes [object Object] in grooming error messages by extracting .message from plain AgentError objects. All changes are scoped to error-reporting paths only and leave runtime behavior unchanged.

Confidence Score: 4/5

Safe to merge — all changes are scoped to error-reporting paths and leave runtime behavior unchanged.

No P0 or P1 issues found. The string-based heuristic in path-prober.ts for classifying expected errors is slightly brittle if upstream error messages ever change, keeping this at 4 rather than 5.

src/main/agents/path-prober.ts — the expected-error detection relies on substring matching against error message text.

Important Files Changed

Filename Overview
src/main/agents/path-prober.ts Adds string-based heuristic to skip Sentry for known timeout/non-zero-exit probe failures; approach is slightly brittle if error message text ever changes but is well-commented and functionally correct.
src/main/cue/cue-db.ts Clean early-return guard on null db in both safe wrappers; prevents the DB-not-initialized path from ever reaching the try/catch that previously sent to Sentry.
src/main/ipc/handlers/git.ts ENOENT filter applied consistently in both scanWorktreeDirectory and watchWorktreeDirectory catch blocks; unexpected error codes still escalate to Sentry.
src/main/utils/context-groomer.ts Fixes [object Object] stringification by extracting .message from plain AgentError objects; handles Error, object-with-message, and primitive fallback cleanly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Error caught] --> B{path-prober: timeout / non-zero exit?}
    B -->|Yes| C[Skip Sentry, log debug]
    B -->|No| D[captureException]

    E[Error caught in git.ts] --> F{code === ENOENT?}
    F -->|Yes| G[Log only, skip Sentry]
    F -->|No| H[captureException]

    I[safeRecordCueEvent / safeUpdateCueEventStatus called] --> J{db === null?}
    J -->|Yes| K[log warn, return early — skip Sentry]
    J -->|No| L[Try DB write]
    L -->|throws| M[log warn + captureException]

    N[agent-error event] --> O{error instanceof Error?}
    O -->|Yes| P[use error.message]
    O -->|No| Q{typeof error === 'object' and .message present?}
    Q -->|Yes| R["String(error.message)"]
    Q -->|No| S["String(error)"]
    P & R & S --> T[reject with Grooming error message]
Loading

Reviews (1): Last reviewed commit: "fix(sentry): suppress recoverable errors..." | Re-trigger Greptile

@pedramamini pedramamini merged commit 273ec6c into rc Apr 28, 2026
5 checks passed
@pedramamini pedramamini deleted the fix/sentry-rc-noise branch April 28, 2026 14:04
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.

1 participant