⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

googleGenAIIntegration wraps multi-element array responses in nested arrays #18793

@arik-mesh

Description

@arik-mesh

Is there an existing issue for this?

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

  1. Configure googleGenAIIntegration with @sentry/[email protected]
  2. Use @google/[email protected] to call the Gemini API
  3. Send a prompt that requests multiple items (e.g., "Extract all line items from this receipt")
  4. 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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions