Skip to content

feat(node): Migrate Node AI provider to dataCollection option#21247

Open
s1gr1d wants to merge 1 commit into
developfrom
sig/node-ai-provider-data-collection
Open

feat(node): Migrate Node AI provider to dataCollection option#21247
s1gr1d wants to merge 1 commit into
developfrom
sig/node-ai-provider-data-collection

Conversation

@s1gr1d
Copy link
Copy Markdown
Member

@s1gr1d s1gr1d commented May 29, 2026

Closes #20930

@s1gr1d s1gr1d requested a review from a team as a code owner May 29, 2026 12:32
@s1gr1d s1gr1d requested review from JPeer264, andreiborza, chargome and nicohrubec and removed request for a team May 29, 2026 12:32
*/
private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {
const client = getClient();
const genAI = client?.getDataCollectionOptions().genAI;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The code client?.getDataCollectionOptions().genAI may throw a TypeError. If client is undefined, accessing .genAI on the resulting undefined will cause a crash.
Severity: HIGH

Suggested Fix

Add optional chaining to the .genAI property access to prevent the TypeError. The corrected code should be client?.getDataCollectionOptions()?.genAI.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/node/src/integrations/tracing/langgraph/instrumentation.ts#L94

Potential issue: The code at
`packages/node/src/integrations/tracing/langgraph/instrumentation.ts:94` uses optional
chaining for `client` but not for the subsequent property access. If `getClient()`
returns `undefined`, which can happen if a module using `@langchain/langgraph` is loaded
before `Sentry.init()` is called, the expression `client?.getDataCollectionOptions()`
evaluates to `undefined`. The following access to `.genAI` on `undefined` will then
throw a `TypeError: Cannot read properties of undefined (reading 'genAI')`, causing a
crash.

Also affects:

  • packages/core/src/tracing/ai/utils.ts:52~52

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.17 kB - -
@sentry/browser - with treeshaking flags 25.62 kB - -
@sentry/browser (incl. Tracing) 45.25 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.47 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.22 kB - -
@sentry/browser (incl. Tracing, Replay) 84.83 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.39 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 89.53 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.15 kB - -
@sentry/browser (incl. Feedback) 44.34 kB - -
@sentry/browser (incl. sendFeedback) 31.98 kB - -
@sentry/browser (incl. FeedbackAsync) 37.08 kB - -
@sentry/browser (incl. Metrics) 28.25 kB - -
@sentry/browser (incl. Logs) 28.48 kB - -
@sentry/browser (incl. Metrics & Logs) 29.19 kB - -
@sentry/react 28.99 kB - -
@sentry/react (incl. Tracing) 47.51 kB - -
@sentry/vue 32.2 kB - -
@sentry/vue (incl. Tracing) 47.16 kB - -
@sentry/svelte 27.19 kB - -
CDN Bundle 29.55 kB - -
CDN Bundle (incl. Tracing) 47.81 kB - -
CDN Bundle (incl. Logs, Metrics) 31.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.04 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.31 kB - -
CDN Bundle (incl. Tracing, Replay) 85.18 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.05 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.21 kB - -
CDN Bundle - uncompressed 87.59 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.09 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 92.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.85 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 216.81 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.87 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.3 kB - -
@sentry/nextjs (client) 50.03 kB - -
@sentry/sveltekit (client) 45.68 kB - -
@sentry/core/server 75.93 kB +0.01% +2 B 🔺
@sentry/core/browser 63.09 kB +0.01% +4 B 🔺
@sentry/node-core 61.69 kB - -
@sentry/node 130.45 kB +0.04% +52 B 🔺
@sentry/node - without tracing 74.1 kB - -
@sentry/aws-serverless 86.29 kB - -
@sentry/cloudflare (withSentry) - minified 171.5 kB - -
@sentry/cloudflare (withSentry) 429.29 kB - -

View base workflow run

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.

(node): Migrate Node.js AI provider integrations to dataCollection

1 participant