Skip to content

Commit bbcb2a0

Browse files
committed
more fixes
1 parent bc2a62f commit bbcb2a0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sentry_sdk/integrations/google_genai/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def accumulate_streaming_response(chunks):
5151
for chunk in chunks:
5252
# Extract text and tool calls
5353
if getattr(chunk, "candidates", None):
54-
for candidate in chunk.candidates:
54+
for candidate in getattr(chunk, "candidates", []):
5555
if hasattr(candidate, "content") and getattr(
5656
candidate.content, "parts", []
5757
):

sentry_sdk/integrations/google_genai/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def _extract_response_text(response):
394394
# type: (GenerateContentResponse) -> Optional[List[str]]
395395
"""Extract text from response candidates."""
396396

397-
if not response or not hasattr(response, "candidates"):
397+
if not response or not getattr(response, "candidates", []):
398398
return None
399399

400400
texts = []
@@ -412,11 +412,11 @@ def _extract_response_text(response):
412412
def extract_finish_reasons(response):
413413
# type: (GenerateContentResponse) -> Optional[List[str]]
414414
"""Extract finish reasons from response candidates."""
415-
if not response or not hasattr(response, "candidates"):
415+
if not response or not getattr(response, "candidates", []):
416416
return None
417417

418418
finish_reasons = []
419-
for candidate in getattr(response, "candidates", []):
419+
for candidate in response.candidates:
420420
if getattr(candidate, "finish_reason", None):
421421
# Convert enum value to string if necessary
422422
reason = str(candidate.finish_reason)

0 commit comments

Comments
 (0)