Skip to content

TypeError: 'NoneType' object is not iterable in google_genai integration #5854

@jerome-duckbill

Description

@jerome-duckbill

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.50.0

Steps to Reproduce

  1. Make a Gemini call where a candidate's content.parts is explicitly None (attribute present but set to None)
  2. Sentry's tracing fires and calls _extract_response_text
  3. hasattr check passes (attribute exists), then iterating over None crashes

Expected Result

No exception is raised. Sentry skips recording the response text span attribute when content.parts is None.

Actual Result

TypeError: 'NoneType' object is not iterable
Traceback points to _extract_response_text in sentry_sdk/integrations/google_genai/utils.py.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions