Skip to content

Handle null response output in parser - #3407

Closed
lxingy3 wants to merge 1 commit into
openai:mainfrom
lxingy3:fix-null-response-output-parse
Closed

Handle null response output in parser#3407
lxingy3 wants to merge 1 commit into
openai:mainfrom
lxingy3:fix-null-response-output-parse

Conversation

@lxingy3

@lxingy3 lxingy3 commented Jun 17, 2026

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Handle response.output = None in parse_response() by treating it the same as an empty output list. This prevents the parser from raising TypeError when a terminal Responses payload has a null output field.

The PR also adds a focused regression test that constructs a completed Response with output=None and verifies parsing returns an empty output list.

Closes #3312.

Additional context & links

Local checks run:

  • PYTHONPATH=src python -m pytest tests/lib/responses/test_parse_response.py -q -o addopts=""
  • PYTHONPATH=src python -m ruff check src/openai/lib/_parsing/_responses.py tests/lib/responses/test_parse_response.py
  • python -m ruff format src/openai/lib/_parsing/_responses.py tests/lib/responses/test_responses.py tests/lib/responses/test_parse_response.py

@marcuswood-oai

Copy link
Copy Markdown
Contributor

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!

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