{{ message }}
Repository navigation
fix(schema): validate canonical base64 without a backtracking regex - #51272
Open
darellchua2 wants to merge 1 commit into
Open
darellchua2 wants to merge 1 commit into
darellchua2 wants to merge 1 commit into
Conversation
Contributor
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Author
This was referenced Oct 13, 2026
This was referenced Oct 14, 2026
This was referenced Oct 14, 2026
This branch has not been deployed
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.

Issue for this PR
Closes #45558
Closes #50336
Type of change
What does this PR do?
In the wild this surfaces as
Error: Schema validation failed ... Prompt.Base64 ... InvalidValuewithPOST /api/session/<id>/prompt http.status=500in the server log.Prompt.Base64used a(?:X{4})*regex, which regex engines evaluate with per-group recursion. Past a few MB the check stops working: on Bun/JSC (the runtime the shipped binary embeds) it silently returnsfalsefor canonical base64, and on V8 it throws RangeError. SincematerializeAttachmentbase64-encodes attachments up to 20 MB, any@-attached file over ~5 MB failedPOST /api/session/:id/promptwith a 500 before reaching the provider.The check is now a length preflight, a single-pass alphabet pattern, and a padding/length consistency test. Canonical base64 always has length ≡ 0 (mod 4), alphabet chars with at most two trailing pads, and 0, 2, or 3 data chars in the final quantum, so accept/reject behavior is unchanged for every input.
How did you verify your code works?
cd packages/schema && bun test— new tests cover the padding edge cases and a 20 MB payload (passes in ~32 ms; the old pattern returnedfalseon it). I also fuzzed 20k mutated canonical strings against the old pattern with zero accept/reject mismatches, checked on Bun 1.4.2 (JSC) and Node 24 (V8).bun run checkpasses.Screenshots / recordings
Not a UI change.
Checklist
Analysis and repro: attachments: dragging file or pasting file path into input fails session setup (Prompt.Base64 500 on /prompt) #45558 (comment)
(The
needs:issuelabel from the bot is stale —Closes #45558/Closes #50336are above; GitHub doesn't record closing references for PRs targeting non-default branches, which is why the GraphQL check comes up empty.)