From 126f3f54496a1b85b5c5958a91d112f68ae30d59 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 21 May 2026 11:02:13 +0200 Subject: [PATCH] fix(google-genai): Guard against None response ID and response model --- sentry_sdk/integrations/google_genai/streaming.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sentry_sdk/integrations/google_genai/streaming.py b/sentry_sdk/integrations/google_genai/streaming.py index 7f3f58dc93..05b2318f5b 100644 --- a/sentry_sdk/integrations/google_genai/streaming.py +++ b/sentry_sdk/integrations/google_genai/streaming.py @@ -123,10 +123,13 @@ def set_span_data_for_streaming_response( safe_serialize(accumulated_response["tool_calls"]), ) - if accumulated_response.get("id"): - span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, accumulated_response["id"]) - if accumulated_response.get("model"): - span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, accumulated_response["model"]) + response_id = accumulated_response.get("id") + if response_id is not None: + span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, response_id) + + response_model = accumulated_response.get("model") + if response_model is not None: + span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response_model) if accumulated_response["usage_metadata"] is None: return