Skip to content

fix(mcp): keep repo regex/session and MCP-server tool noise out of Sentry - #1333

Merged
kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-batch-kody-cloudflare-kody-cloudflare-49-5bf9
Aug 8, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-batch-kody-cloudflare-kody-cloudflare-49-5bf9

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Intent

Stop routine caller-correctable MCP failures from opening Sentry platform-bug issues during agent repo/MCP workflows.

Summary

Fixes https://kent-c-dodds-tech-llc.sentry.io/issues/7660915384/
Fixes https://kent-c-dodds-tech-llc.sentry.io/issues/7660931122/
Fixes https://kent-c-dodds-tech-llc.sentry.io/issues/7660974902/

Testing

  • Focused unit tests for caller-error helpers, repo_search, MCP-server synthesis handler, observability filters
  • npm run validate (local green on pre-review revision)
  • Focused unit tests green after CodeRabbit follow-ups
System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 446e1f1e · Head: 6e3ac66f

Classification: composes — wires existing McpCallerError / isCallerFailure classification into repo search, inactive sessions, and MCP-server tool failures; no new primitives or schema changes.

Primitives touched

Primitive Group Impact
capability-registry assistant composes — repo_search invalid regex → McpCallerError
mcp-client-servers assistant composes — downstream tool failures → McpCallerError
mcp-server surfaces composes — observability message match for DO-crossing caller errors
repo-sessions runtime composes — fail-fast invalid-regex guidance + stable phrase helpers

System map

Caller-correctable repo/MCP-server failures classify as non-Sentry MCP failures while remaining visible on mcp-event lines.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	repoSessions["repo-sessions<br/>Repo session DO"]:::touched
	capabilityRegistry["capability-registry<br/>Capability registry"]:::touched
	mcpClientServers["mcp-client-servers<br/>User MCP servers"]:::touched
	mcpServer["mcp-server<br/>MCP endpoint"]:::touched
	repoSessions -->|"invalid regex / inactive session"| capabilityRegistry
	mcpClientServers -->|"downstream tool failure"| capabilityRegistry
	capabilityRegistry -->|"throw McpCallerError"| mcpServer
	mcpServer -->|"isCallerFailure skips Sentry"| mcpServer
	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
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messages for invalid repository search patterns.
    • Added guidance that regex searches use JavaScript RegExp syntax, with literal search available by default.
    • Standardized handling of unavailable repository sessions and downstream tool failures while preserving useful failure details.
    • Prevented expected caller-input errors from being reported as service failures.
  • Tests

    • Expanded coverage for invalid patterns, unavailable sessions, tool failures, and observability behavior.

…ntry

Classify invalid repo_search JavaScript regexes, inactive/published repo
sessions, and downstream user-connected MCP server tool failures as
caller-clearable so they stay on mcp-event instead of opening platform-bug
issues (KODY-CLOUDFLARE-49/4A/4B).

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

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change standardizes caller-facing errors for repository search and downstream MCP server calls. It preserves original causes, adds JavaScript regular-expression guidance, and classifies matching failures as caller failures in observability.

Changes

MCP caller error handling

Layer / File(s) Summary
Caller-error message contracts
packages/worker/src/repo/repo-session-caller-error.ts, packages/worker/src/repo/repo-session-search.ts, packages/worker/src/repo/*.test.ts
Adds stable predicates and messages for inactive sessions and invalid JavaScript regular expressions.
Repository search error mapping
packages/worker/src/mcp/capabilities/repo/*
repo_search wraps invalid-regex failures in McpCallerError and preserves unrelated failures. Schemas and descriptions document JavaScript RegExp syntax.
MCP server failure wrapping
packages/worker/src/mcp/capabilities/mcp-server/*
Authentication and tool-call failures now throw McpCallerError instances with original causes.
Caller-failure observability
packages/worker/src/mcp/observability*
Cause-chain checks classify inactive-session, invalid-regex, and downstream MCP failures as caller failures. Tests cover the added events.

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

Sequence Diagram(s)

sequenceDiagram
  participant MCPCaller
  participant repo_search
  participant repoSessionRpc
  participant observability
  MCPCaller->>repo_search: submit repository search
  repo_search->>repoSessionRpc: execute search
  repoSessionRpc-->>repo_search: return result or caller error
  repo_search-->>MCPCaller: return result or McpCallerError
  MCPCaller->>observability: classify failure
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: preventing repository and MCP-server caller errors from creating Sentry noise.
Description check ✅ Passed The description includes the required Intent, Summary, and Testing sections, with relevant implementation details and validation evidence.
✨ Finishing Touches 💡 1
📝 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-batch-kody-cloudflare-kody-cloudflare-49-5bf9

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 August 8, 2026 21:43
@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

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

Worker: kody-pr-1333
D1: kody-pr-1333-db
KV: kody-pr-1333-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.

Actionable comments posted: 2

🤖 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 `@packages/worker/src/mcp/capabilities/repo/repo-search.ts`:
- Around line 1-9: Update the repo-search error handling helper used by
isRepoSearchInvalidRegexMessage to return the matching nested cause message, and
pass that message to McpCallerError instead of the outer getErrorMessage(error).
Preserve the outer error as the McpCallerError cause and retain existing
behavior for non-matching errors.

In `@packages/worker/src/repo/repo-session-search.ts`:
- Line 1: Move regex construction and validation out of searchInText and into
the main repository search flow after query normalization, before iterating
workspace files, so invalid patterns consistently raise the caller error even
for empty or unreadable workspaces. Reuse the resulting compiled regex during
file scanning, and add a regression test covering an empty workspace with an
invalid pattern.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b07eab7-44da-4e4c-93f1-37302795ea56

📥 Commits

Reviewing files that changed from the base of the PR and between 446e1f1 and b4cd3dc.

📒 Files selected for processing (11)
  • packages/worker/src/mcp/capabilities/mcp-server/index.ts
  • packages/worker/src/mcp/capabilities/mcp-server/mcp-server-caller-error.node.test.ts
  • packages/worker/src/mcp/capabilities/repo/repo-search.node.test.ts
  • packages/worker/src/mcp/capabilities/repo/repo-search.ts
  • packages/worker/src/mcp/capabilities/repo/repo-shared.ts
  • packages/worker/src/mcp/observability.node.test.ts
  • packages/worker/src/mcp/observability.ts
  • packages/worker/src/repo/repo-session-caller-error.node.test.ts
  • packages/worker/src/repo/repo-session-caller-error.ts
  • packages/worker/src/repo/repo-session-search.node.test.ts
  • packages/worker/src/repo/repo-session-search.ts

Comment thread packages/worker/src/mcp/capabilities/repo/repo-search.ts Outdated
Comment thread packages/worker/src/repo/repo-session-search.ts
Compile mode=regex before scanning files so empty workspaces still reject
Python/PCRE patterns, and map nested DO errors to the matching guidance
message in McpCallerError (CodeRabbit on #1333).

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kody-bot
kody-bot merged commit c1cab0f into main Aug 8, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-batch-kody-cloudflare-kody-cloudflare-49-5bf9 branch August 8, 2026 23:57
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