diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index 28b54a8bcd..4ac58ca70d 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -696,6 +696,9 @@ def _extract_response_text( if not hasattr(candidate, "content") or not hasattr(candidate.content, "parts"): continue + if candidate.content is None or candidate.content.parts is None: + continue + for part in candidate.content.parts: if getattr(part, "text", None): texts.append(part.text)