Skip to content

fix: treat null message content as empty in parse_response - #3841

Open
soroush5 wants to merge 1 commit into
openai:mainfrom
soroush5:fix/null-message-content-responses-parse
Open

fix: treat null message content as empty in parse_response#3841
soroush5 wants to merge 1 commit into
openai:mainfrom
soroush5:fix/null-message-content-responses-parse

Conversation

@soroush5

Copy link
Copy Markdown

Fixes #3840.

One-line change in src/openai/lib/_parsing/_responses.py: iterate output.content or [], mirroring the response.output or [] guard #3345 added for #3325. A message item with content: null now parses to a message with empty content instead of raising TypeError: 'NoneType' object is not iterable.

Validation: new tests/lib/responses/test_null_content.py fails before (4 failures, sync+async, streaming explicit-output and non-streaming parse) and passes after. Neighbor suites pass: tests/lib 1694 passed / 83 skipped (excluding the mock-server-dependent fine-tuning file), ./scripts/lint clean.

@soroush5
soroush5 requested a review from a team as a code owner September 10, 2026 07:30
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.

parse_response crashes with TypeError when a message item has content:null

1 participant