Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/pydantic_ai/spans/ai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
if not response:
return

set_data_normalized(span, SPANDATA.GEN_AI_RESPONSE_MODEL, response.model_name)
span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response.model_name)

Check warning on line 210 in sentry_sdk/integrations/pydantic_ai/spans/ai_client.py

View workflow job for this annotation

GitHub Actions / warden: find-bugs

Missing attribute check for response.model_name causes unhandled AttributeError

Line 210 accesses `response.model_name` without checking if the attribute exists, and it's outside the try-except block. If the response object doesn't have a `model_name` attribute, this will raise an unhandled `AttributeError` that propagates to the caller. The similar code in `invoke_agent.py` (line 168) correctly uses `if hasattr(response, "model_name") and response.model_name:` before accessing the attribute.
try:
# Extract text from ModelResponse
if hasattr(response, "parts"):
Expand Down
Loading