Skip to content

fix(types): make ResponseFunctionWebSearch.action Optional - #3626

Open
Xsidz wants to merge 1 commit into
openai:mainfrom
Xsidz:fix/web-search-action-optional
Open

fix(types): make ResponseFunctionWebSearch.action Optional#3626
Xsidz wants to merge 1 commit into
openai:mainfrom
Xsidz:fix/web-search-action-optional

Conversation

@Xsidz

@Xsidz Xsidz commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixes #3179.

The API returns web_search_call items with action=null for completed searches (observed when results come from cache). The action field was typed as non-optional Action, so any code accessing item.action.type raised AttributeError: 'NoneType' object has no attribute 'type'.

Changed action: Action to action: Optional[Action] = None in both the responses/ and beta/ variants of ResponseFunctionWebSearch.

Test plan

  • tests/test_models.py and tests/test_transform.py: 114 passed, 0 failures.
  • Ruff lint: all checks passed.
  • Verified Optional was already imported in both files — no import changes needed.

Fixes openai#3179: the API can return a web_search_call item with action=null
(observed on completed searches that returned cached results). The field
was typed as non-optional, causing AttributeError at action.type access.

Applied to both responses/ and beta/ variants.
@Xsidz
Xsidz requested a review from a team as a code owner August 16, 2026 16:52
Copilot AI lite review requested due to automatic review settings August 16, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

ResponseFunctionWebSearch doesn't match returned payload

2 participants