feat(node): Migrate Node AI provider to dataCollection option#21247
Open
s1gr1d wants to merge 1 commit into
Open
feat(node): Migrate Node AI provider to dataCollection option#21247s1gr1d wants to merge 1 commit into
dataCollection option#21247s1gr1d wants to merge 1 commit into
Conversation
| */ | ||
| private _patch(exports: PatchedModuleExports): PatchedModuleExports | void { | ||
| const client = getClient(); | ||
| const genAI = client?.getDataCollectionOptions().genAI; |
Contributor
There was a problem hiding this comment.
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.
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20930