-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
@sentry/[email protected]
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
import * as Sentry from '@sentry/aws-serverless';
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.environment,
integrations: [
Sentry.captureConsoleIntegration({ levels: ['error'] }),
Sentry.googleGenAIIntegration({
recordInputs: true,
recordOutputs: true
})
],
tracesSampleRate: 1.0,
sendDefaultPii: true,
});
Steps to Reproduce
- Configure
googleGenAIIntegrationwith@sentry/[email protected] - Use
@google/[email protected]to call the Gemini API - Send a prompt that requests multiple items (e.g., "Extract all line items from this receipt")
- The API correctly returns a multi-element array, but the response is mutated
Expected Result
When the Google GenAI SDK returns a multi-element array:
[
{"description": "Item A", "amount": 100},
{"description": "Item B", "amount": 200},
{"description": "Item C", "amount": 300}
]The response should remain unchanged.
Actual Result
The googleGenAIIntegration wraps each element in an additional array:
[
[{"description": "Item A", "amount": 100}],
[{"description": "Item B", "amount": 200}],
[{"description": "Item C", "amount": 300}]
]Additional Context
- Single-element arrays are NOT affected - only multi-element arrays
- Single objects are NOT affected
- The bug appears to occur during response instrumentation for recording purposes
- Workaround: Normalize the response by detecting and flattening the nested array pattern:
function normalizeArrayResponse(data: any): any {
if (!Array.isArray(data)) return data;
const isBugPattern = data.length > 1 && data.every(
(item) => Array.isArray(item) && item.length === 1 &&
typeof item[0] === 'object' && item[0] !== null
);
return isBugPattern ? data.map((item) => item[0]) : data;
}Environment
- Node.js version: 22.x
- Runtime: AWS Lambda
- @sentry/aws-serverless: 10.33.0
- @google/genai: 1.15.0
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Product Owner