Skip to content

fix: add None checks to prevent __dict__ crash on optional tool attributes#1288

Open
MaxwellCalkin wants to merge 1 commit intoAgentOps-AI:mainfrom
MaxwellCalkin:fix-none-dict-crash-tool-attributes
Open

fix: add None checks to prevent __dict__ crash on optional tool attributes#1288
MaxwellCalkin wants to merge 1 commit intoAgentOps-AI:mainfrom
MaxwellCalkin:fix-none-dict-crash-tool-attributes

Conversation

@MaxwellCalkin
Copy link

Summary

Fix AttributeError: 'NoneType' object has no attribute '__dict__' crash in tool attribute extraction.

Fixes #1285.

Problem

Three hasattr() checks in the tool attribute extraction guard calls to .__dict__ on optional fields. But hasattr() returns True even when the attribute value is None, causing a crash:

ERROR:openai.agents:Error in trace processor ... during on_span_end: 'NoneType' object has no attribute '__dict__'

Affected fields:

  • WebSearchTool.user_location (line 507)
  • FileSearchTool.filters (line 525)
  • FileSearchTool.ranking_options (line 531)

Fix

Add is not None checks alongside the existing hasattr() guards:

# Before
if hasattr(tool, "user_location"):
    parameters["user_location"] = tool.user_location.__dict__

# After
if hasattr(tool, "user_location") and tool.user_location is not None:
    parameters["user_location"] = tool.user_location.__dict__

Same pattern applied to all three affected fields.

This PR was authored by Claude Opus 4.6 (AI). Human partner: @MaxwellCalkin

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AttributeError: 'NoneType' object has no attribute '__dict__' in get_response_tool_web/file_search_attributes

1 participant