Skip to content

fix(responses): guard parse_response against null response.output - #3629

Open
Xsidz wants to merge 1 commit into
openai:mainfrom
Xsidz:fix/parse-response-null-output
Open

fix(responses): guard parse_response against null response.output#3629
Xsidz wants to merge 1 commit into
openai:mainfrom
Xsidz:fix/parse-response-null-output

Conversation

@Xsidz

@Xsidz Xsidz commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixes #3312 (and the related duplicates #3314, #3321, #3325, #3313).

parse_response() in src/openai/lib/_parsing/_responses.py iterates response.output unconditionally. Several backends (chatgpt.com Codex, OAI-compatible servers under load) emit response.completed with output: null, which causes:

TypeError: 'NoneType' object is not iterable

One-character fix: response.output or [] short-circuits to an empty list when the field is null, returning a ParsedResponse with an empty output list rather than crashing.

Test plan

  • tests/test_models.py, tests/test_transform.py, tests/lib/responses/: 121 passed, 0 failures.
  • Ruff lint: all checks passed.

Fixes openai#3312: when a response.completed event carries output=null
(observed against chatgpt.com/backend-api/codex/responses and other
OAI-compatible backends), parse_response iterated None and raised
TypeError. Use `response.output or []` to short-circuit.
@Xsidz
Xsidz requested a review from a team as a code owner August 16, 2026 17:36
Copilot AI lite review requested due to automatic review settings August 16, 2026 17:36

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.

responses.stream crashes with TypeError: 'NoneType' object is not iterable when server emits response.completed with output=None

2 participants