Skip to content

Commit b80dd97

Browse files
ericapisaniclaude
andcommitted
fix(pydantic-ai): Safely access tool description attribute
Use getattr with a None default when accessing tool_definition.description to prevent AttributeError if the attribute is missing. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent a0bd0dc commit b80dd97

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def execute_tool_span(
3939
span.set_data(SPANDATA.GEN_AI_TOOL_NAME, tool_name)
4040

4141
if tool_definition:
42-
span.set_data(SPANDATA.GEN_AI_TOOL_DESCRIPTION, tool_definition.description)
42+
span.set_data(
43+
SPANDATA.GEN_AI_TOOL_DESCRIPTION,
44+
getattr(tool_definition, "description", None),
45+
)
4346

4447
_set_agent_data(span, agent)
4548

0 commit comments

Comments
 (0)