fix(marketing): skip the API read for a malformed fight handle

Merged
SU
17d ago
+2-0

Problem

/fight?a=…&b=… failed to render when a query value was not a valid leaderboard handle, for example a handle with a trailing ) from a pasted link. The server render threw an unhandled tRPC input-validation error.

Root cause

resolveFighter sent the raw query value to leaderboard.public.participant. That procedure's handleSchema refuses anything outside HANDLE_PATTERN, or a reserved handle, with BAD_REQUEST. fetchParticipant returns null only for NOT_FOUND and rethrows all other errors, so the render failed. #7295 fixed the same problem for profile routes: there the proxy routes to a profile only when isProfileHandle passes. The fight page had no such check.

Fix

Use the same isProfileHandle check in resolveFighter before the API read. If the handle is not valid, that slot is empty, which is what a missing profile already shows.

Verification

$ bunx biome check "src/app/[lang]/fight/page.tsx"
Checked 1 file in 32ms. No fixes applied.

$ cd apps/marketing && bun run typecheck
$ tsc --noEmit
(no errors)

$ bun test "src/app/[lang]/fight"
 11 pass
 0 fail
Ran 11 tests across 1 file.

Refs MARKETING-6C


Summary by cubic

Fixes the /fight page render failing when a query value is not a valid leaderboard handle. resolveFighter sent the raw value to leaderboard.public.participant, which rejects malformed handles (like pasted links with a trailing )) with BAD_REQUEST; fetchParticipant rethrows everything except NOT_FOUND, so the page crashed.

The page now uses the same isProfileHandle check used for profile routes before the API read. Invalid handles render as an empty slot, matching the missing-profile state.

Summary by CodeRabbit

  • Bug Fixes
    • Invalid fighter profile handles are now rejected before participant details load, preventing malformed handles from appearing as valid fighters.
    • House fighters continue to be resolved first.