Skip to content

fix(mcp): stop reporting sandbox execute failures to Sentry - #917

Merged
kody-bot merged 1 commit into
mainfrom
cursor/sentry-triage-7631441133-812b
Jul 24, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/sentry-triage-7631441133-812b

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Sentry issue 7631441133 (Unknown: path must be an absolute Notion API path…) is a warning with tags mcp.sandbox_error=true / mcp.tool=execute: a caller execute module passed a non-absolute Notion API path. That is a user/module error, not a platform defect.

logMcpEvent already records these on the structured mcp-event log line. Forwarding them to Sentry opens warning issues that look like platform bugs and spawn triage agents. This PR skips Sentry capture when sandboxError is true; real MCP/platform failures still report at error level.

Same root-cause fix as #915 (cherry-picked). Many sibling unresolved /mcp warnings share mcp.sandbox_error=true and will stop recurring once this deploys.

Test plan

  • observability.node.test.ts asserts sandbox failures still emit mcp-event but do not call captureMessage / captureException, while non-sandbox failures still report
  • Pre-push hooks ran unit + e2e on push
  • npm run validate / CI green
System recap — extends existing primitives (medium risk)

Mode: recap · Base: main @ 49893e20 · Head: 02ce0e6f

Classification: extends — changes MCP failure reporting so sandbox/user-module errors stay on logs only and no longer open Sentry issues.

Primitives touched

Primitive Group Impact
mcp-server surfaces extends — sandbox execute failures no longer reported to Sentry

System map

Sandbox execute failures used to become Sentry warnings via MCP observability; they now stay on the mcp-event log path only.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context.

flowchart LR
	mcpExecute["mcp execute<br/>sandbox run"]:::untouched
	mcpEvent["mcp-event log"]:::untouched
	observability["mcp-server<br/>observability"]:::extended
	sentry["Sentry"]:::untouched
	mcpExecute -->|"result.error"| observability
	observability -->|"always"| mcpEvent
	observability -->|"platform failures only"| sentry
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Before: execute sandbox failures (sandboxError: true) were captured in Sentry as warnings (Unknown: …), including caller Notion path validation errors.

After: sandbox failures remain on mcp-event logs; only non-sandbox MCP failures are sent to Sentry at error level.

Risk and invariants

  • Medium: changes production error visibility for one failure class; does not touch auth, storage isolation, or capability contracts.
  • Per-user isolation unchanged; Sentry user id attachment for platform MCP failures is unchanged.

Docs

No doc updates; behavior is an observability policy change covered by unit tests.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Sandbox-related MCP failures no longer generate Sentry error reports.
    • Other MCP failures continue to be reported at error severity with relevant context.
  • Tests
    • Added coverage to verify MCP event logging and Sentry reporting behavior for sandbox and non-sandbox failures.

Caller/module errors (bad Notion filters, thrown strings, syntax issues)
already land on mcp-event logs. Sending them to Sentry as warnings opens
noise issues that look like platform bugs and trip triage automation.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

MCP sandbox failures now bypass Sentry reporting, while non-sandbox failures are captured at error level. A new test verifies MCP logging, Sentry capture behavior, and scope configuration.

Changes

MCP observability

Layer / File(s) Summary
Sentry reporting behavior and validation
packages/worker/src/mcp/observability.ts, packages/worker/src/mcp/observability.node.test.ts
Sandbox failures return without Sentry calls; reportable failures use error severity. Tests verify event logging, capture behavior, and Sentry scope configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 clearly and concisely matches the main change: sandbox MCP failures are no longer reported to Sentry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-triage-7631441133-812b

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.

@kody-bot
kody-bot marked this pull request as ready for review July 24, 2026 18:45
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-917.kody-a99.workers.dev

Worker: kody-pr-917
D1: kody-pr-917-db
KV: kody-pr-917-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/worker/src/mcp/observability.ts (1)

61-71: 🩺 Stability & Availability | 🔵 Trivial

Sandbox errors now have zero Sentry visibility — confirm log-based alerting covers the gap.

Since sandbox failures no longer reach Sentry, the only remaining signal is the mcp-event console log line. Worth confirming there's log-based monitoring/alerting on sandboxError: true spikes so regressions in sandbox execution aren't silently missed.

🤖 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 `@packages/worker/src/mcp/observability.ts` around lines 61 - 71, Verify that
the structured mcp-event logging path records sandboxError: true and has active
log-based monitoring or alerting for spikes in those events. If coverage is
missing, add the necessary alerting using the existing observability conventions
while keeping sandbox errors excluded from Sentry.
packages/worker/src/mcp/observability.node.test.ts (1)

63-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing coverage for the captureMessage fallback branch.

reportMcpFailureToSentry has two capture paths: captureException for Error causes and captureMessage when cause isn't an Error but errorMessage is set. Only the captureException path is exercised here; captureMessage is only asserted as not called (sandbox case). Consider adding a third case (non-sandbox, non-Error cause, non-empty errorMessage) to cover the captureMessage branch.

🤖 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 `@packages/worker/src/mcp/observability.node.test.ts` around lines 63 - 102,
Extend the observability test around the existing MCP failure cases to add a
non-sandbox failure with a non-Error cause and non-empty errorMessage,
exercising reportMcpFailureToSentry’s captureMessage fallback. Assert that
sentryMock.captureMessage is called with the expected message while preserving
the existing captureException assertions for Error causes.
🤖 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.

Nitpick comments:
In `@packages/worker/src/mcp/observability.node.test.ts`:
- Around line 63-102: Extend the observability test around the existing MCP
failure cases to add a non-sandbox failure with a non-Error cause and non-empty
errorMessage, exercising reportMcpFailureToSentry’s captureMessage fallback.
Assert that sentryMock.captureMessage is called with the expected message while
preserving the existing captureException assertions for Error causes.

In `@packages/worker/src/mcp/observability.ts`:
- Around line 61-71: Verify that the structured mcp-event logging path records
sandboxError: true and has active log-based monitoring or alerting for spikes in
those events. If coverage is missing, add the necessary alerting using the
existing observability conventions while keeping sandbox errors excluded from
Sentry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f70906b-7503-4789-9b38-1c036586201b

📥 Commits

Reviewing files that changed from the base of the PR and between 32d97b7 and 02ce0e6.

📒 Files selected for processing (2)
  • packages/worker/src/mcp/observability.node.test.ts
  • packages/worker/src/mcp/observability.ts

@kody-bot
kody-bot merged commit c6e9b1f into main Jul 24, 2026
7 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-7631441133-812b branch July 24, 2026 18:51
kody-bot pushed a commit that referenced this pull request Jul 24, 2026
* Keep expected MCP caller errors out of Sentry

Capability handlers throw plain Errors for caller mistakes (missing
arguments, ids that do not resolve, preconditions the caller must clear)
and every one of them opened a Sentry issue that reads like a platform
bug. Five of the fourteen open kody-cloudflare issues are this class.

Adds McpCallerError so a failure site can say the caller caused it,
skips Sentry for parse_input failures (arguments never matched the
declared schema), and adds a callerError payload flag for the search
paths that report a caller mistake without throwing.

Extends the same carve-out #916 and #917 made for connector disconnects
and sandbox execute failures.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

* Stop reporting OpenAPI missing path params to Sentry

Caller mistakes like omitting organization_id_or_slug were thrown as
plain Errors from buildOperationUrl and opened Sentry issues that look
like platform bugs (KODY-CLOUDFLARE-1S). Throw McpCallerError instead so
observability keeps them on mcp-event logs only.

* Only skip Sentry for caller-attributed search batch failures

Review feedback: a total entity-batch failure could hide platform
incidents when every lookup failed for DB/load reasons. Preserve
per-entry McpCallerError provenance and set callerError only when all
failures are caller mistakes. Also mark search-detail not-found paths
as McpCallerError.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

3 participants