Skip to content

Fix: Nullable Enum Schema#1024

Open
yiedpozi wants to merge 1 commit into
prism-php:mainfrom
yiedpozi:fix/nullable-enum-schema
Open

Fix: Nullable Enum Schema#1024
yiedpozi wants to merge 1 commit into
prism-php:mainfrom
yiedpozi:fix/nullable-enum-schema

Conversation

@yiedpozi

Copy link
Copy Markdown

Description

Append null to the enum array when nullable is true.

When nullable: true is set on EnumSchema, null is added to the type field but not to the enum array. Without null as an explicit enum option, the LLM does not treat it as a valid choice, so instead of returning null for unrecognised values, it picks the closest match from the list.

Reference:
https://community.openai.com/t/assign-null-when-information-not-available-in-structured-outputs/907624

wishborn added a commit to Particle-Academy/prism that referenced this pull request Jul 6, 2026
wishborn added a commit to Particle-Academy/prism that referenced this pull request Jul 6, 2026
…ertions

Follow-up to prism-php#1024 — nullable enums now correctly include null
in their JSON Schema enum list, but Gemini expresses nullability via its
`nullable` flag and rejects null enum values, so the Gemini SchemaMap filters
them out.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
wishborn added a commit to Particle-Academy/prism that referenced this pull request Jul 6, 2026
- MessageMap (prism-php#971): guard first() against null before
  accessing reasoning properties.
- EnumSchema (prism-php#1024): add value types to options() docblock.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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