Skip to content

fix(ui): keep OIDC query params as strings to fix invalid_value error - #2

Merged
Summpot merged 1 commit into
mainfrom
summpot-bookish-system
Aug 6, 2026
Merged

fix(ui): keep OIDC query params as strings to fix invalid_value error#2
Summpot merged 1 commit into
mainfrom
summpot-bookish-system

Conversation

@Summpot

@Summpot Summpot commented Aug 6, 2026

Copy link
Copy Markdown
Owner

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 on JSON.parse) coerces query-string values into booleans/numbers, so oidc=1 arrives as the number 1. The oidcSearchSchema expects a string literal via z.literal('1'), so validation fails and the login page cannot render the OIDC flow.

Approach

Configure the router in src/router.tsx with a string-preserving parseSearch/stringifySearch. This keeps every query value as a raw string, so z.literal('1') validates correctly and the isOidcFlow (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

  • Verified against zod v4 (invalid_value reproduces exactly when a number 1 is passed to z.literal('1')) and verified the string-preserving parser round-trips correctly for oidc=1, URL-encoded redirect URIs, and spaced state values.
  • Other routes using search params (profile) also expect string values, so the string-preserving behavior is safe and consistent.

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>
@Summpot
Summpot merged commit 872bb0b into main Aug 6, 2026
11 checks passed
@Summpot
Summpot deleted the summpot-bookish-system branch August 6, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant