Skip to content

fix: render athlete pages instead of 404ing on every profile#256

Merged
rootulp merged 1 commit into
mainfrom
fix/athlete-page-404-shard-decode
Jul 16, 2026
Merged

fix: render athlete pages instead of 404ing on every profile#256
rootulp merged 1 commit into
mainfrom
fix/athlete-page-404-shard-decode

Conversation

@rootulp

@rootulp rootulp commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Problem

Multiple users (a Reddit comment with 7 upvotes, then reproduced directly: searching Rootul Patel β†’ /athlete/rootul-patel--us-m β†’ 404, despite 12 real races) hit a 404 when clicking a search result through to an athlete's profile.

Root cause

The /athlete/[slug] edge page fetches a gzipped profile shard and relied on a hand-set Content-Encoding: gzip header so the HTTP layer would auto-decompress it. Vercel's CDN does not honor that header on public/ assets, so the edge fetch received raw gzip, res.json() threw, the failure was swallowed, and getAthleteProfile returned null β†’ notFound() β†’ a 404 for every real athlete. It worked locally only because next start honors the header.

The search shards already avoid this by decompressing explicitly β€” the athlete shards took the fragile shortcut.

Fix

  • Serve athlete-shards as raw gzip (Content-Type: application/gzip, no Content-Encoding), mirroring the search shards.
  • Decompress explicitly in the edge runtime with fflate (pure JS β€” DecompressionStream is blocked in Next's edge runtime and zlib is Node-only). Detect the gzip magic bytes so it also works where the server transfer-decompresses the response.
  • Throw on a genuine load failure instead of returning null, so a real athlete never renders a false "not found"; only a missing slug within a successfully-loaded shard is a true 404.

Testing

  • Added/updated unit tests in athlete-shards.test.ts (raw-gzip decode, already-decompressed body, throw-on-failure instead of false 404). Full suite: 160 passed, lint clean.
  • Verified end-to-end against a production build serving shards as raw gzip (mirroring Vercel): athlete profiles render (200); previously this path 404'd.

πŸ€– Generated with Claude Code

The /athlete/[slug] edge page fetched a gzipped profile shard and relied
on a hand-set `Content-Encoding: gzip` header so the HTTP layer would
auto-decompress it. Vercel's CDN does not honor that header on public/
assets, so the edge fetch received raw gzip, `res.json()` threw, the
failure was swallowed, and `getAthleteProfile` returned null β€” rendering
a 404 for every real athlete (reproduced via search: Rootul Patel, 12
races, 404'd). It worked locally only because `next start` honors the
header.

- Serve athlete-shards as raw gzip (Content-Type: application/gzip, no
  Content-Encoding), mirroring the search shards.
- Decompress explicitly in the edge runtime with fflate (pure JS β€”
  DecompressionStream is blocked in Next's edge runtime and zlib is
  Node-only). Detect the gzip magic bytes so it also handles servers
  that transfer-decompress the response.
- Throw on a genuine load failure (non-ok / undecodable) instead of
  returning null, so a real athlete never renders a false "not found";
  only a missing slug within a loaded shard is a true 404.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaVB6YHWz94LTY8AGVc88Q
@rootulp rootulp self-assigned this Jul 16, 2026
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tritimes Ready Ready Preview, Comment Jul 16, 2026 5:06am

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rootulp, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fafbbef6-ee5d-48de-8dd9-a695f0f74009

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 3da6590 and 01bda60.

β›” Files ignored due to path filters (1)
  • app/package-lock.json is excluded by !**/package-lock.json
πŸ“’ Files selected for processing (4)
  • app/next.config.ts
  • app/package.json
  • app/src/lib/__tests__/athlete-shards.test.ts
  • app/src/lib/athlete-shards.ts
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/athlete-page-404-shard-decode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@rootulp
rootulp enabled auto-merge (squash) July 16, 2026 05:03
@rootulp
rootulp merged commit 1deab37 into main Jul 16, 2026
7 checks passed
@rootulp
rootulp deleted the fix/athlete-page-404-shard-decode branch July 16, 2026 05:06
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