fix(gemini): strip data URI prefix from PDF base64 data#14110
Closed
404-Page-Found wants to merge 1 commit intoCherryHQ:v2from
Closed
fix(gemini): strip data URI prefix from PDF base64 data#14110404-Page-Found wants to merge 1 commit intoCherryHQ:v2from
404-Page-Found wants to merge 1 commit intoCherryHQ:v2from
Conversation
DeJeune
approved these changes
Apr 8, 2026
Collaborator
|
Note This issue/comment/review was translated by Claude. It can be merged to v1, please revise the PR according to the guidelines. Original Content可以合并到v1,根据规范重新改一下pr |
Contributor
Author
|
Note This issue/comment/review was translated by Claude. New PR URL |
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.
What this PR does
Before this PR:
Uploading a PDF file and sending it to Gemini-3.1-pro-preview (or other Gemini models via certain proxies) failed with a "Base64 decoding failed" error because the payload incorrectly included the
data:application/pdf;base64,prefix.After this PR:
The application correctly strips the Data URI prefix from the base64 data for PDF files, ensuring only the raw base64 string is sent to the API.
Fixes #14097
Why we need it and why it was done in this way
Certain API proxies or specific model versions are stricter about the
inline_data.dataformat and do not handle the Data URI prefix. Stripping it ensures compatibility across different providers while remaining compliant with the expected standard of raw base64 for these fields.The following tradeoffs were made:
The following alternatives were considered:
Breaking changes
None.
Special notes for your reviewer
I've verified that
base64Filereturns raw base64 inFileStorage.ts, but added this defensive check infileProcessor.tsto ensure that any data passed to the AI SDK is clean.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note