fix(codex): handle response.completed with output=None on chatgpt.com backend#34544
Closed
ericwangzq wants to merge 1 commit into
Closed
fix(codex): handle response.completed with output=None on chatgpt.com backend#34544ericwangzq wants to merge 1 commit into
ericwangzq wants to merge 1 commit into
Conversation
… backend The chatgpt.com/backend-api/codex endpoint sends a response.completed event with output=None instead of a list. The OpenAI SDK's parse_response() iterates over response.output, causing: TypeError: 'NoneType' object is not iterable This was classified as a non-retryable local validation error, aborting every request to the openai-codex provider. Fix: catch TypeError in _run_codex_stream and check for the NoneType iteration message. By the time response.completed fires, all content has already arrived via response.output_item.done stream events (collected in collected_output_items) and text deltas (_codex_streamed_text_parts). Build a synthetic response object from that collected data and return it normally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Closing — the upstream has already addressed this more thoroughly in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chatgpt.com/backend-api/codexendpoint sendsresponse.completedwithoutput=Noneinstead of a listparse_response()doesfor output in response.output:which raisesTypeError: 'NoneType' object is not iterableopenai-codexprovider to abort immediatelyRoot cause
In
_run_codex_stream, the stream event loop callsself._state.handle_event(sse_event)for each event. Whenresponse.completedarrives,ResponseStreamState.accumulate_event()callsparse_response()which iterates overresponse.output. On the chatgpt.com backend this field isNone, triggering the TypeError.The existing
excepthandlers only caught_httpxtransport errors andRuntimeError—TypeErrorpropagated up to the retry loop whereis_local_validation_error = isinstance(api_error, TypeError)caused immediate abort.Fix
Catch
TypeErrorwith'NoneType' object is not iterablein_run_codex_stream. By the timeresponse.completedfires, all content has already arrived:response.output_item.doneevents →collected_output_itemsself._codex_streamed_text_partsBuild a synthetic response from that collected data and return normally, reusing the same backfill pattern already present in the function.
Test plan
provider: openai-codexandmodel: gpt-5.5pointing tohttps://chatgpt.com/backend-api/codexTypeError: 'NoneType' object is not iterable🤖 Generated with Claude Code