Skip to content

fix: serve static fallback trophy card instead of broken error page - #3

Closed
CynthiaWahome wants to merge 2 commits into
masterfrom
fix/trophy-fallback-card
Closed

fix: serve static fallback trophy card instead of broken error page#3
CynthiaWahome wants to merge 2 commits into
masterfrom
fix/trophy-fallback-card

Conversation

@CynthiaWahome

Copy link
Copy Markdown

Summary

  • requestUserInfo() failures (bad token, rate limit, or a genuinely missing user) all collapse into the same ServiceError/NOT_FOUND path, which rendered the app's "Not Found" HTML error page with a 404 status — visibly broken to anyone viewing the README.
  • Since this endpoint is only ever called with a hardcoded real username, the actual cause in practice has been GITHUB_TOKEN1 being invalid (see the matching fix in cynthia-readme-cards for the stats card, same root cause pattern: token rejected, error path taken instead of showing real data).

Fix

  • scripts/generate-fallback-trophy.ts renders one real snapshot of the trophy card via the live Card/theme renderer, run manually with a valid token (GITHUB_TOKEN1=$(gh auth token) deno run --allow-net --allow-env --allow-write=public,src scripts/generate-fallback-trophy.ts).
  • Output committed as public/fallback-trophy.svg (for manual review) and src/fallbackTrophy.ts (imported by the API).
  • api/index.ts now serves that static SVG with status 200 whenever requestUserInfo() fails, instead of the error page. Degraded state is only detectable via the X-Trophy-Source: fallback response header or view-source (HTML comment) — never visible in the rendered card.
  • Removed the now-unused ErrorPage import.

Test plan

  • deno check api/index.ts — no new errors (12 pre-existing errors in src/error_page.ts, confirmed present before this change too via git stash)
  • Manually generated and inspected public/fallback-trophy.svg — real data, renders correctly
  • After merge/deploy, confirm GITHUB_TOKEN1 in Vercel env vars is still valid — same as the readme-cards PR, this fix makes failures invisible to visitors but doesn't fix why the token is being rejected.

The trophy card was returning its own "Not Found" HTML error page
(status 404) any time GithubApiService.requestUserInfo() failed —
which happens for a genuinely missing user, a rate limit, AND a bad
GITHUB_TOKEN1, all collapsed into the same ServiceError/NOT_FOUND
path. In practice, since this endpoint only ever gets called with a
hardcoded real username from the README, the actual cause has always
been the token, and visitors were seeing an obviously-broken page
instead of a trophy card.

Added scripts/generate-fallback-trophy.ts, which renders a real
snapshot of the card using the live Card/theme renderer (run with a
valid token, e.g. `gh auth token`, since this script itself is not
part of the request-time path). The output is committed as
public/fallback-trophy.svg (for manual review) and src/fallbackTrophy.ts
(what api/index.ts actually imports and serves).

api/index.ts now serves that static SVG with a 200 status whenever
requestUserInfo() returns a ServiceError, so visitors always see a
normal-looking trophy card. The degraded state is only detectable via
the X-Trophy-Source: fallback response header or view-source — never
by looking at the rendered card. Removed the now-unused ErrorPage
import.

Mirrors the same fallback pattern just applied to the stats card in
cynthia-readme-cards.
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cynthia-profile-trophy Ready Ready Preview Aug 1, 2026 9:48am

vercel.json had a top-level "public": true field, which was a Vercel
Platform v1 setting (deployment visibility) that the current schema no
longer accepts. Every redeploy was failing outright with:

  Invalid request. Should NOT have additional property "public"

Removing it doesn't change any actual behavior -- it was already
inert under the current platform version, just still present in the
config file and now actively rejected by validation.
@CynthiaWahome

Copy link
Copy Markdown
Author

Closing — this was mistakenly based on master (stale, upstream-tracking) instead of feat/cynthia-custom-trophies (the actual active branch). Redone correctly in #4.

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