Skip to content

fix: handle null response output text#3400

Open
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/nullable-response-output-text
Open

fix: handle null response output text#3400
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/nullable-response-output-text

Conversation

@he-yufeng

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 None when the API returns a nullable output_text.text item.
  • Make Response.output_text skip null text items instead of failing or appending a non-string value.
  • Make responses.parse(...) leave null output_text items unparsed while still parsing later non-null output text items.
  • Add regression coverage for both Response.output_text and the structured parse path.

Additional context & links

Fixes #3063.

I know the repository is generated; this PR is intended to pin down the runtime behavior and regression tests for the nullable API payload shape.

Verification:

  • PYTHONPATH=src python -m pytest tests\lib\responses\test_responses.py -q
  • python -m ruff check src\openai\types\responses\response_output_text.py src\openai\types\responses\response.py src\openai\lib\_parsing\_responses.py tests\lib\responses\test_responses.py
  • python -m pyright src\openai\types\responses\response_output_text.py src\openai\types\responses\response.py src\openai\lib\_parsing\_responses.py tests\lib\responses\test_responses.py
  • python -m ruff format --check src\openai\types\responses\response_output_text.py src\openai\types\responses\response.py src\openai\lib\_parsing\_responses.py tests\lib\responses\test_responses.py
  • git diff --check

@he-yufeng he-yufeng requested a review from a team as a code owner June 13, 2026 22:14

@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: 897ce0a518

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".



def _response_with_output_text_items(items: list[dict[str, Any]]) -> Response:
return Response.model_validate(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use v1-compatible validation in test helper

In the test-pydantic-v1 nox session, noxfile.py installs pydantic<2 and runs the whole pytest suite, but this helper now calls Response.model_validate(...) unconditionally. The SDK's BaseModel does not shim model_validate for pydantic v1, so that CI path will fail with AttributeError before these regressions run. Use the repo's compatibility helper or Response.parse_obj(...) here instead.

Useful? React with 👍 / 👎.

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.

Response.output_text and responses.parse fail when an output_text item has text: null

1 participant