Skip to content

fix(sentry): stop reporting user-module esbuild failures from workflows - #926

Merged
kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-7631743981-6d09
Jul 24, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/sentry-triage-7631743981-6d09

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes KODY-CLOUDFLARE-1X (Error: Build failed with 1 error: / failureErrorWithLog).

An inline Cloudflare Workflow ran caller-supplied code with a broken regex:

subject.match(/[([^/]+)/([^]]+)].*(PR #(d+))/i)

esbuild failed with Unexpected "^" under virtual:.__kody_root__/entry.ts. The workflow correctly marked the run as errored and rethrew; Sentry.instrumentWorkflowWithSentry then opened a Sentry issue that looks like a platform bug.

MCP execute already catches the same bundler failures and reports them as sandbox/caller errors (not Sentry). This PR adds a narrow beforeSend filter for the shared signature (Build failed with + .__kody_root__/) so workflow auto-capture matches that policy. Unrelated build failures without the user-module path still report.

Test plan

  • sentry-options.node.test.ts asserts the user-module bundler signature is dropped, platform-path build failures and unrelated errors are kept, and the combined filter still drops D1 lock noise
  • Pre-push hooks (unit + e2e) passed on push
  • CI npm run validate green
System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 569128cb · Head: b1acae8e

Classification: composes — narrow Sentry beforeSend filter only; no primitive contracts or workflow execution behavior changed.

Primitives touched

Primitive Group Impact
(unmatched) sentry-options.ts observability composes — drops user-module esbuild failures already handled as workflow run errors

System map

Inline workflow bundler failures still fail the workflow run; Sentry no longer opens a platform issue for the same caller mistake.

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

flowchart LR
	inlineWorkflow["workflows<br/>Inline workflow run"]:::untouched
	bundler["worker-bundler / esbuild<br/>.__kody_root__ build"]:::untouched
	sentryFilter["sentry-options<br/>beforeSend filter"]:::touched
	inlineWorkflow -->|"execute inline code"| bundler
	bundler -->|"Build failed with … __kody_root__"| sentryFilter
	sentryFilter -->|"drop event"| dropped["Sentry issue skipped"]:::untouched
	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

Change flow

sequenceDiagram
	participant WF as DynamicCallableWorkflow
	participant Bundle as buildKodyModuleBundle
	participant Sentry as beforeSend
	WF->>Bundle: inline entry.ts
	Bundle-->>WF: Build failed (__kody_root__)
	WF->>WF: mark workflow_runs errored, rethrow
	WF->>Sentry: auto.faas.cloudflare.workflow
	Sentry-->>Sentry: filter drops event
Loading
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Reduced misleading error reports by suppressing Sentry events caused by user-module bundling failures.
    • Continued suppressing retryable database lock contention events.
    • Preserved reporting for platform build failures and unrelated error details.
  • Tests
    • Added coverage to ensure Sentry filtering behavior correctly suppresses user-module bundling failures while keeping other relevant events.

Inline workflow runs rethrow caller bundler errors (Build failed with …
virtual:.__kody_root__/…), and Cloudflare workflow instrumentation opens
Sentry issues that look like platform bugs. MCP execute already treats
these as sandbox errors; filter the same signature in beforeSend.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bba14d1-45fc-45f6-900b-dda2106a9847

📥 Commits

Reviewing files that changed from the base of the PR and between b1acae8 and 72693ac.

📒 Files selected for processing (1)
  • packages/worker/src/sentry-options.node.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/worker/src/sentry-options.node.test.ts

📝 Walkthrough

Walkthrough

Sentry event handling now suppresses user-module esbuild bundling failures alongside retryable D1 lock contention. The combined filter is wired into beforeSend, with tests covering suppression and preservation of relevant event categories.

Changes

Sentry filtering

Layer / File(s) Summary
Bundler failure filter
packages/worker/src/sentry-options.ts
Adds message extraction and detection for user-module esbuild failures, then combines that filter with retryable D1 lock suppression.
Filter wiring and validation
packages/worker/src/sentry-options.ts, packages/worker/src/sentry-options.node.test.ts
Routes Sentry beforeSend through the combined filter and tests bundler-failure, platform-failure, unrelated-event, and D1-lock behavior.

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

Possibly related PRs

  • kentcdodds/kody#685: Updates the existing Sentry beforeSend and retryable D1 lock filtering behavior touched by this change.
🚥 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 matches the main change: suppressing Sentry reports for user-module esbuild failures from workflows.
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-7631743981-6d09

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 22:27
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Worker: kody-pr-926
D1: kody-pr-926-db
KV: kody-pr-926-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 (1)
packages/worker/src/sentry-options.node.test.ts (1)

29-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the event.message candidate path.

The helper now matches both top-level event.message and exception.values[*].value, but this test only supplies the latter. Add a case with the full signature in message and no exception payload.

Suggested test
+	const userModuleMessageFailure = {
+		message:
+			'Build failed with 1 error:\nvirtual:.__kody_root__/entry.ts:11:49: ERROR: Unexpected "^"',
+	}
+	expect(filterSentryEvent(userModuleMessageFailure)).toBeNull()
🤖 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/sentry-options.node.test.ts` around lines 29 - 67, The
test should also cover the top-level event.message path handled by
filterUserModuleBundlerFailureSentryEvent and filterSentryEvent. Add a
user-module esbuild failure case whose complete signature is in message and that
has no exception payload, then assert both filters return null while preserving
the existing exception.values cases.
🤖 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/sentry-options.node.test.ts`:
- Around line 29-67: The test should also cover the top-level event.message path
handled by filterUserModuleBundlerFailureSentryEvent and filterSentryEvent. Add
a user-module esbuild failure case whose complete signature is in message and
that has no exception payload, then assert both filters return null while
preserving the existing exception.values cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a4ec8ffe-86a3-417f-9872-b8ab6673842f

📥 Commits

Reviewing files that changed from the base of the PR and between 2845228 and b1acae8.

📒 Files selected for processing (2)
  • packages/worker/src/sentry-options.node.test.ts
  • packages/worker/src/sentry-options.ts

CodeRabbit noted sentryEventMessages also reads event.message; assert that
shape is dropped without an exception payload.
@kody-bot
kody-bot merged commit 887d5ba into main Jul 24, 2026
5 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-7631743981-6d09 branch July 24, 2026 22:44
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