Skip to content

Handle null response output_text items - #3062

Closed
texasich wants to merge 4 commits into
openai:mainfrom
texasich:main
Closed

Handle null response output_text items#3062
texasich wants to merge 4 commits into
openai:mainfrom
texasich:main

Conversation

@texasich

@texasich texasich commented Apr 6, 2026

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

Changes being requested

  • allow ResponseOutputText.text to be nullable during response parsing
  • skip null output_text items in Response.output_text
  • add a regression test covering a response payload with one null text item and one normal text item

Additional context & links

This addresses issue #3011, where accessing Response.output_text can fail when an output_text content item contains text: null.

Verification:

  • ran tests/lib/responses/test_responses.py
  • all tests in that file passed locally

texasich and others added 2 commits April 5, 2026 22:00
## Summary
Fix handling of `response.output_text` items when the API returns `text: null`.

## Changes
- allow `ResponseOutputText.text` to be nullable during response parsing
- skip null `output_text` items in `Response.output_text`
- add a regression test covering a response payload with one null text item and one normal text item

## Verification
- ran `tests/lib/responses/test_responses.py`
- all tests in that file passed locally

## Context
Addresses issue openai#3011, where accessing `Response.output_text` can fail when an `output_text` content item contains `text: null`.
@texasich
texasich requested a review from a team as a code owner April 6, 2026 03:11

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6dc33f03d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/types/responses/response_output_text.py
@texasich

texasich commented Apr 6, 2026

Copy link
Copy Markdown
Author

Opened a tracking issue for the bug here: #3063

I also pushed a follow-up fix for the structured parsing path so responses.parse(...) skips null output_text items as well.

@texasich

Copy link
Copy Markdown
Author

👋 Friendly ping — this has been open for ~7 weeks. Is this something you'd like merged, or should I close it? Happy to rebase if there's been any drift.

@texasich texasich closed this May 30, 2026
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.

1 participant