Skip to content

fix(parsing): handle None response.output in parse_response to preven… - #3415

Closed
Vitaliy-Pikalo wants to merge 1 commit into
openai:mainfrom
Vitaliy-Pikalo:fix-parse-response-none-output-typeerror
Closed

fix(parsing): handle None response.output in parse_response to preven…#3415
Vitaliy-Pikalo wants to merge 1 commit into
openai:mainfrom
Vitaliy-Pikalo:fix-parse-response-none-output-typeerror

Conversation

@Vitaliy-Pikalo

Copy link
Copy Markdown

Fixes #3325

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

parse_response in src/openai/lib/_parsing/_responses.py iterates directly over response.output without guarding against None. When the Responses API returns a response with output=null (e.g. a content-filtered or empty response), this crashes with:

TypeError: 'NoneType' object is not iterable

Fix: Replace:

for output in response.output:

With:

for output in (response.output or []):

This makes the behavior safe when response.output is None, treating it as an empty list and returning an empty ParsedResponse.

Additional context & links

@Vitaliy-Pikalo
Vitaliy-Pikalo requested a review from a team as a code owner June 21, 2026 08:23
@marcuswood-oai

Copy link
Copy Markdown
Contributor

Thank you for the contribution! The null-output parsing and stream recovery fix has landed in #3345, so I am closing this PR as superseded. We appreciate your help!

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.

parse_response crashes with TypeError when response.output is null in response.completed event (chatgpt.com Codex backend)

2 participants