Fix validation error for file parser image elements#235
Merged
mattapperson merged 1 commit intoOpenRouterTeam:mainfrom Nov 24, 2025
Merged
Conversation
The file-parser plugin returns content arrays containing both text and image elements. Image elements (type: "image_url") do not have a text property, causing validation errors. This change makes the text field optional to support both element types whilst maintaining backwards compatibility with text-only content. Fixes validation error: "Invalid input: expected string, received undefined" Signed-off-by: Sora Morimoto <sora@morimoto.io>
e64fb35 to
a7cf99b
Compare
|
+1 this is needed |
subtleGradient
added a commit
that referenced
this pull request
Nov 25, 2025
subtleGradient
added a commit
that referenced
this pull request
Nov 25, 2025
subtleGradient
added a commit
that referenced
this pull request
Nov 25, 2025
Merged
kesavan-byte
pushed a commit
to osm-API/ai-sdk-provider
that referenced
this pull request
Feb 13, 2026
…rTeam#235) The file-parser plugin returns content arrays containing both text and image elements. Image elements (type: "image_url") do not have a text property, causing validation errors. This change makes the text field optional to support both element types whilst maintaining backwards compatibility with text-only content. Fixes validation error: "Invalid input: expected string, received undefined" Signed-off-by: Sora Morimoto <sora@morimoto.io>
kesavan-byte
pushed a commit
to osm-API/ai-sdk-provider
that referenced
this pull request
Feb 13, 2026
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.
Problem
When the
file-parserplugin processes PDFs containing images using the Mistral OCR engine, it returns annotations with acontentarray that includes both text and image elements. Image elements have the structure{"type":"image_url","image_url":{...}}without atextproperty, causing validation failures.Solution
Make the
textfield optional in the file annotation content schema (lines 116 and 240 insrc/chat/schemas.ts).Changes
text: z.string()totext: z.string().optional()in both non-stream and stream response schemasRelated
Builds upon #232 which added
.passthrough()for forward compatibility.