Skip to content

Commit a66281a

Browse files
fix(google-genai): Guard against None response ID and response model (getsentry#6314)
1 parent 0788e52 commit a66281a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

sentry_sdk/integrations/google_genai/streaming.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,13 @@ def set_span_data_for_streaming_response(
123123
safe_serialize(accumulated_response["tool_calls"]),
124124
)
125125

126-
if accumulated_response.get("id"):
127-
span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, accumulated_response["id"])
128-
if accumulated_response.get("model"):
129-
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, accumulated_response["model"])
126+
response_id = accumulated_response.get("id")
127+
if response_id is not None:
128+
span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, response_id)
129+
130+
response_model = accumulated_response.get("model")
131+
if response_model is not None:
132+
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response_model)
130133

131134
if accumulated_response["usage_metadata"] is None:
132135
return

0 commit comments

Comments
 (0)