Skip to content

Fix: None case handling in response.output parsing#3320

Closed
JenuelDev wants to merge 1 commit into
openai:mainfrom
JenuelDev:patch-1
Closed

Fix: None case handling in response.output parsing#3320
JenuelDev wants to merge 1 commit into
openai:mainfrom
JenuelDev:patch-1

Conversation

@JenuelDev
Copy link
Copy Markdown

This pull request makes a small but important change to the response parsing logic to improve robustness when handling API responses.

  • Improved error handling in parse_response within src/openai/lib/_parsing/_responses.py by ensuring the code safely iterates over response.output even if it is None, preventing possible runtime errors.

It seems that sometimes the response.output returns null and it throws an error.
@JenuelDev JenuelDev requested a review from a team as a code owner May 27, 2026 03:15
@iqdoctor
Copy link
Copy Markdown

Thanks for the quick fix. This is a duplicate of the earlier PR:

#3315

This PR applies the same parse_response() guard for response.output is None. #3315 already includes that guard and additionally covers:

  • regression coverage for the parser path
  • Response.output_text with output=None
  • streaming ResponseStreamState preservation so an empty/null terminal completed response does not discard already-accumulated streamed output

I compared the diff and did not find extra behavior here that needs to be pulled into #3315.

@JenuelDev
Copy link
Copy Markdown
Author

Going to close this PR then.

@JenuelDev JenuelDev closed this May 28, 2026
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.

2 participants