From 11406fa3a0a3b36cb55ff22601cd9d35753c820e Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 25 Mar 2026 16:45:40 +0100 Subject: [PATCH] fix(google-genai): Guard response extraction --- sentry_sdk/integrations/google_genai/utils.py | 3 +++ 1 file changed, 3 insertions(+) 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)