fix(ai-openai): allow null for Batch.model, output_file_id, error_file_id#2146
Closed
lindit wants to merge 2 commits into
Closed
fix(ai-openai): allow null for Batch.model, output_file_id, error_file_id#2146lindit wants to merge 2 commits into
lindit wants to merge 2 commits into
Conversation
OpenAI returns `status_details: null` on /v1/files responses, but the OpenAPI spec marks it optional-only, so createFile / retrieveFile / listFiles failed decoding with `Expected string, got null at ["status_details"]`. Patched the codegen spec to mark the field nullable and regenerated. Note: the regen also picks up unrelated upstream OpenAPI spec drift since the last regeneration on 2026-04-22. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…e_id OpenAI returns `null` for these fields at various stages of the batch lifecycle (model: null until validation, output_file_id: null until completion, error_file_id: null unless errors occurred), but the OpenAPI spec marks them optional-only. createBatch / retrieveBatch / listBatches fail decoding with `Expected string, got null at [<field>]`. Patched the codegen spec to mark all three nullable. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 68f6fd5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
Closing — squashing into #2145. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #2145. Same class of bug, different schema: OpenAI returns
nullfor severalBatchfields that the OpenAPI spec marks as optional-only.Batch.model—nullon freshly created batches that haven't been validated yet (observed downstream).Batch.output_file_id—nulluntil the batch completes successfully (likely; not yet observed in the wild but obvious candidate).Batch.error_file_id—nullunless errors occurred (likely; not yet observed but obvious candidate).createBatch/retrieveBatch/listBatchesfail decoding with:This PR adds three JSON Patch entries to
packages/ai/openai/codegen.yamlsettingnullable: trueon each (mirroring the precedent set by #2145 and the existingModelResponseProperties.user/safety_identifier/prompt_cache_keypatches). After regen, each field is emitted as:Note: stacked on #2145
This branch is built on top of
fix/openai-files-status-details-null(#2145), so GitHub will show that PR's commit until #2145 merges tomain. TheGenerated.tsdiff unique to this PR is small and surgical (3 fields, 13 ins / 9 del):Note:
Batch.errorsnot patched (generator bug)While sweeping, I noticed OpenAI's own example shows
"errors": null(Batch component, line 40127 of the spec). I tried addingnullable: trueforBatch.errorstoo, but the generator handlesnullable: trueon object-typed properties incorrectly — it produces a degenerateSchema.Union([Schema.Struct(...)])with noSchema.Nullmember, and the corresponding TS type is unchanged. The string-typed fields in this PR work fine because the generator handlesnullable: trueon primitive-typed properties correctly.I dropped that patch from the PR per the original guidance not to touch the generator. Worth filing as a separate generator bug; the workaround is to express it via
anyOf: [{...object schema...}, {type: 'null'}]instead ofnullable: true, which is significantly more verbose to encode as a JSON Patch.Test plan
pnpm --filter @effect/ai-openai checkpassespnpm --filter @effect/ai-openai testpasses (90 tests)pnpm --filter @effect/ai-openai buildpassescreateBatchagainst the live OpenAI API and confirm response decodes whenmodel: null🤖 Generated with Claude Code