Skip to content

fix(OpenAI): default missing optional keys to null in from()#786

Merged
iBotPeaches merged 1 commit into
openai-php:mainfrom
lazerg:issue-781
Jul 6, 2026
Merged

fix(OpenAI): default missing optional keys to null in from()#786
iBotPeaches merged 1 commit into
openai-php:mainfrom
lazerg:issue-781

Conversation

@lazerg

@lazerg lazerg commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

WebSearchUserLocation::from() and OutputMcpCall::from() read their nullable keys straight from $attributes, so a response that omits those optional keys triggers an "Undefined array key" warning. This defaults them to null with ?? null, the same way the other from() methods already handle optional keys.

Related:

fixes: #781

@iBotPeaches

Copy link
Copy Markdown
Collaborator

Any further context on the set_error_handler usage? None of our other tests do that, so curious what you hit or trying to test with that.

@lazerg

lazerg commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Undefined array key only warns in PHP, doesn't throw. Value's null either way, so a plain assertion wouldn't catch the regression without escalating it. Scoped to that one call via try/finally so it doesn't leak into other tests.

@iBotPeaches iBotPeaches added this to the v0.20.1 milestone Jul 6, 2026
@iBotPeaches iBotPeaches merged commit b13f46f into openai-php:main Jul 6, 2026
14 checks passed
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.

Unchecked access to optional keys in $attributes in public static function from() in multiple classes.

2 participants