Handle null response output during parsing - #3330
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5de32017b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
d9b78c4 to
a6aa9c2
Compare
|
Rebased this branch onto the current |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6aa9c2a0a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
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! |
Summary
Fixes #3325.
parse_response()currently assumesresponse.outputis always iterable. Some streaming backends can send a finalresponse.completedpayload withoutput: nullafter emitting valid output-item events, which causes a bareTypeErrorin the response stream accumulator.This change:
output: null;\n- applies refusal, content-part, and output-item finalization events before recovering that output;The branch has been rebased onto the current
mainand the prior test-file conflict is resolved.Tests
pytest tests/lib/responses/test_responses.py -q— 11 passedruff check src/openai/lib/_parsing/_responses.py src/openai/lib/streaming/responses/_responses.py tests/lib/responses/test_responses.pyruff format --check src/openai/lib/_parsing/_responses.py src/openai/lib/streaming/responses/_responses.py tests/lib/responses/test_responses.pyscripts/run-pyright src/openai/lib/_parsing/_responses.py src/openai/lib/streaming/responses/_responses.py tests/lib/responses/test_responses.pygit diff --check