fix(ui): keep OIDC query params as strings to fix invalid_value error - #2
Merged
Conversation
TanStack Router's default parseSearch coerces query-string values into
booleans/numbers via JSON.parse, so oidc=1 arrived as the number 1 and
failed the oidcSearchSchema z.literal('1') validation with an
invalid_value error. Configure a string-preserving parseSearch/
stringifySearch so OIDC params validate correctly.
Co-authored-by: Copilot App <223556219+Copilot@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.
Why
When the Minecraft mod redirects the browser to
/login?oidc=1&..., the login page fails with a zod validation error:{ "code": "invalid_value", "values": ["1"], "path": ["oidc"], "message": "Invalid input" }The root cause is in the frontend, not the backend. TanStack Router's default
parseSearch(built onJSON.parse) coerces query-string values into booleans/numbers, sooidc=1arrives as the number1. TheoidcSearchSchemaexpects a string literal viaz.literal('1'), so validation fails and the login page cannot render the OIDC flow.Approach
Configure the router in
src/router.tsxwith a string-preservingparseSearch/stringifySearch. This keeps every query value as a raw string, soz.literal('1')validates correctly and theisOidcFlow(params.oidc === '1') check works again.The stringify parser deliberately throws for plain strings so they are encoded raw; only structured values (arrays/objects) are JSON-stringified by the helper wrapper.
Notes
invalid_valuereproduces exactly when a number1is passed toz.literal('1')) and verified the string-preserving parser round-trips correctly foroidc=1, URL-encoded redirect URIs, and spacedstatevalues.profile) also expect string values, so the string-preserving behavior is safe and consistent.