Repository navigation
fix(router): don't crash dev response when X-Void-Routing trace is non-ASCII - #226
Merged
Merged
Conversation
❌ Deploy Preview for staging-void-cloud failed.
|
hyfdev
marked this pull request as ready for review
June 18, 2026 15:50
…n-ASCII The dev-only X-Void-Routing trace header set by __voidAnnotateRouting (rewrite / redirect / c.rewrite paths) interpolates the user's rule source/dest into the value. A non-ASCII path (e.g. a CJK or other >U+00FF char) makes that value fail the header ByteString conversion, so the unguarded headers.set threw and crashed the dev response with a 500. The sibling pass-through trace set is already wrapped in try/catch for exactly this reason; apply the same guard to __voidAnnotateRouting so a non-ASCII trace is silently dropped and the response is returned intact. (Completes commit b3b7384, which only ASCII-fixed the framework's own arrow, and the residual of void-sdk/void#54.)
hyfdev
force-pushed
the
fix/dev-routing-trace-non-ascii
branch
from
June 18, 2026 16:06
41187a7 to
e42a5af
Compare
Brooooooklyn
approved these changes
Jun 30, 2026
Member
|
This was already fixed on main, and this is the wrong fix. |
cpojer
pushed a commit
that referenced
this pull request
Sep 11, 2026
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.
A dev request through a rewrite/redirect whose path contains a non-ASCII character (e.g. a CJK route) no longer crashes with a 500 — the dev-only routing trace header now degrades gracefully.
The bug
In dev mode,
__voidAnnotateRouting(the generated helper that adds theX-Void-Routingtrace header for rewrite / redirect /c.rewriteresponses) builds the header value by interpolating the matched rule's user-supplied source/dest (e.g."rewrite[" + source + "] -> " + dest + " (...)"). If the path contains a character > U+00FF (CJK, etc.), that value fails the header ByteString conversion, so the unguardedheaders.set("X-Void-Routing", trace)throws and crashes the response with a 500.Expected-correct behavior
The dev trace header is a debugging convenience — it must never crash the actual response. The sibling pass-through trace set is already wrapped in
try { … } catch {}for exactly this reason (with a test + comment: "silently swallow … instead of crashing, matching the existing pattern elsewhere"), but__voidAnnotateRoutingwas missed.The fix
Wrap the
__voidAnnotateRoutingset intry { headers.set("X-Void-Routing", trace); } catch { return response; }— on throw, silently drop the trace header and return the response intact, matching the pass-through guard. (Production is unaffected: the whole helper is a no-op when__VOID_DEV_ROUTINGis false.)This completes commit
b3b73842("Use ASCII characters in headers only"), which ASCII-fixed only the framework's own→arrow in the trace, not the user-supplied source/dest — and is the residual of the non-ASCII-header crash reported in void-sdk/void#54.Tests
Added a codegen assertion in
compile.test.ts(same style as the existing pass-through-guard test) that the emitted__voidAnnotateRoutingwraps its set in the try/catch — failing onorigin/mainand passing after. (Confirmed independently thatHeaders.setthrows on a > U+00FF value, and that the rule source/dest reach the trace unencoded.) Local gate:compile.test.ts122/122; full--project unitzero-collateral; typecheck + lint + fmt clean.Prepared with AI assistance.