SIGN IN SIGN UP

fix(lib): treat null message content as empty in parse_response (#3851)

## Changes being requested

- [x] I understand that this repository is auto-generated and my pull
request may not be merged

Fixes #3840

`parse_response()` in `src/openai/lib/_parsing/_responses.py` iterates
`output.content` without a null guard, so a message output item with
`content: null` raises `TypeError: 'NoneType' object is not iterable`
instead of parsing:

```python
client.responses.parse(model="...", input="...")
# API returns output: [{"id": ..., "type": "message", "role": "assistant",
#   "status": "completed", "content": null}]
# -> TypeError: 'NoneType' object is not iterable
```

Null reaches the parser because stream events are built without
validation, and the same payload also passes the non-streaming path
(reproduced with a mocked transport, both sync and async). This is the
same class of bug as null `output`, fixed in #3345.

The fix applies the same `or []` idiom used at line 61 for null `output`
(one line). The change is in `src/openai/lib/`, which per
CONTRIBUTING.md is handwritten and never modified by the generator, so
no custom-code budget impact.

## Additional context & links

- Follow-up to #3325 / #3345 (null `output`), one level deeper: message
`content`.
- Regression test added in `tests/lib/responses/test_null_output.py`
next to the existing null-output tests, mirroring the
`test_parse_response_with_null_output` pattern from #3345.
- Verification: reproduced the `TypeError` on current `main`; new test
fails without the fix and passes with it; full `tests/lib/responses/`
suite passes (96 passed); `ruff check` clean on both files; `git diff
--check` clean. Diff is 2 files, +31/−2.

---------

Co-authored-by: Lichao Chen <3780722+chenlichao@users.noreply.github.com>
Co-authored-by: Marcus Wood <marcuswood@openai.com>
L
Lichao Chen committed
fab5283255ad76d9e79e202e1cf46b6eea783f4b
Parent: 56b1708
Committed by GitHub <noreply@github.com> on 9/18/2026, 10:04:37 PM