Skip to content

parse_response crashes on null output from Codex backend stream #3313

Description

@MikeBrew123

Bug

parse_response() in openai/lib/_parsing/_responses.py:61 crashes with TypeError: 'NoneType' object is not iterable when response.output is null.

# Line 61 — no null guard
for output in response.output:  # crashes when output is None

Reproduction

When streaming via the ChatGPT Codex backend (chatgpt.com/backend-api/codex) with model gpt-5.5, the response.completed SSE event contains output: null instead of an empty list. The SDK's stream accumulator calls accumulate_event()parse_response() which iterates response.output without checking for None.

Affected versions: Tested 2.24.0, 2.25.0, 2.30.0, 2.38.0 — all have the same unguarded loop.

Stack trace:

File "openai/lib/streaming/responses/_responses.py", line 360, in accumulate_event
    self._completed_response = parse_response(...)
File "openai/lib/_parsing/_responses.py", line 61, in parse_response
    for output in response.output:
TypeError: 'NoneType' object is not iterable

Fix

# Line 61
for output in (response.output or []):

Environment

  • OpenAI Python SDK: 2.24.0–2.38.0
  • Python: 3.11.15
  • Provider: openai-codex (chatgpt.com/backend-api/codex)
  • Model: gpt-5.5
  • Client: Hermes Agent v0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions