Skip to content

fix(server-utils): Don't capture caller-handled LangGraph errors - #23594

Draft
nicohrubec wants to merge 1 commit into
fix/langchain-instrumentation-error-capturefrom
fix/langgraph-instrumentation-error-capture
Draft

fix(server-utils): Don't capture caller-handled LangGraph errors#23594
nicohrubec wants to merge 1 commit into
fix/langchain-instrumentation-error-capturefrom
fix/langgraph-instrumentation-error-capture

Conversation

@nicohrubec

Copy link
Copy Markdown
Member

Note

Stacked on top of #23593 (LangChain). Review/merge that one first; this PR targets its branch so the diff stays scoped to LangGraph.

LangGraph's compiled-graph invoke wrapper and tool-node wrapper called captureException(error, { handled: false }) and then rethrew. The error rejects invoke() to the caller, so the instrumentation recorded an "unhandled crash" for an error the application handles. This is the same problem fixed for the OpenAI, Anthropic, and Google GenAI client wrappers in #23024, and for LangChain in #23593.

The span is still marked internal_error and the error still propagates to the caller, so only the event goes away, leaving the handled decision to the application boundary.

The integration tests masked these captures with .ignore('event'); those masks are removed.

Related to #23023

LangGraph's compiled-graph invoke and tool-node wrappers called captureException
with handled: false and then rethrew. The error rejects invoke() to the caller,
so the instrumentation recorded an "unhandled crash" for an error the
application handles, the same issue fixed for the client wrappers (#23024) and
LangChain. The span is still marked failed and the error still propagates; only
the event goes away.

The integration tests masked these with .ignore('event'); those masks are removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1d2b83c. Configure here.

createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
test('should instrument LangGraph with default PII settings', async () => {
await createRunner()
.ignore('event')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fix lacks error-path regression test

Low Severity

This fix PR does not add a test that covers the regression. The integration tests only drop .ignore('event') on success-path scenarios, so they would still pass if captureException were restored. A fix PR needs a unit, integration, or E2E test that fails without the change and passes with it: invoke that throws, the caller catching it, and no error event being sent. The related LangChain tests already follow that pattern with an error-model invoke inside try/catch.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 1d2b83c. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB added added
@sentry/browser - with treeshaking flags 26.92 kB added added
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB added added
@sentry/browser (incl. Tracing) 48.5 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 48.52 kB added added
@sentry/browser (incl. Tracing, Profiling) 51.43 kB added added
@sentry/browser (incl. Tracing, Replay) 87.89 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.35 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 92.59 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 105.3 kB added added
@sentry/browser (incl. Feedback) 45.81 kB added added
@sentry/browser (incl. sendFeedback) 33.36 kB added added
@sentry/browser (incl. FeedbackAsync) 38.47 kB added added
@sentry/browser (incl. Metrics) 29.52 kB added added
@sentry/browser (incl. Logs) 29.8 kB added added
@sentry/browser (incl. Metrics & Logs) 30.45 kB added added
@sentry/react 30.33 kB added added
@sentry/react (incl. Tracing) 50.71 kB added added
@sentry/vue 35.64 kB added added
@sentry/vue (incl. Tracing) 50.73 kB added added
@sentry/svelte 28.6 kB added added
CDN Bundle 30.32 kB added added
CDN Bundle (incl. Tracing) 49.02 kB added added
CDN Bundle (incl. Logs, Metrics) 32.54 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 50.89 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 72.91 kB added added
CDN Bundle (incl. Tracing, Replay) 86.47 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.33 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 92.22 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.17 kB added added
CDN Bundle - uncompressed 89.94 kB added added
CDN Bundle (incl. Tracing) - uncompressed 146.64 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.33 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.18 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.92 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.6 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.62 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.28 kB added added
@sentry/nextjs (client) 53.23 kB added added
@sentry/sveltekit (client) 48.92 kB added added
@sentry/core/server 65.11 kB added added
@sentry/core/browser 52.27 kB added added
@sentry/node 121.53 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB added added
@sentry/node - without tracing 87.46 kB added added
@sentry/aws-serverless 95.86 kB added added
@sentry/cloudflare (withSentry) - minified 199.28 kB added added
@sentry/cloudflare (withSentry) 495.43 kB added added

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