fix: serve static fallback trophy card instead of broken error page - #3
Closed
CynthiaWahome wants to merge 2 commits into
Closed
fix: serve static fallback trophy card instead of broken error page#3CynthiaWahome wants to merge 2 commits into
CynthiaWahome wants to merge 2 commits into
Conversation
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.
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Author
|
Closing — this was mistakenly based on |
3 tasks
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.
Summary
requestUserInfo()failures (bad token, rate limit, or a genuinely missing user) all collapse into the sameServiceError/NOT_FOUNDpath, which rendered the app's "Not Found" HTML error page with a 404 status — visibly broken to anyone viewing the README.GITHUB_TOKEN1being invalid (see the matching fix incynthia-readme-cardsfor the stats card, same root cause pattern: token rejected, error path taken instead of showing real data).Fix
scripts/generate-fallback-trophy.tsrenders one real snapshot of the trophy card via the liveCard/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).public/fallback-trophy.svg(for manual review) andsrc/fallbackTrophy.ts(imported by the API).api/index.tsnow serves that static SVG with status 200 wheneverrequestUserInfo()fails, instead of the error page. Degraded state is only detectable via theX-Trophy-Source: fallbackresponse header or view-source (HTML comment) — never visible in the rendered card.ErrorPageimport.Test plan
deno check api/index.ts— no new errors (12 pre-existing errors insrc/error_page.ts, confirmed present before this change too viagit stash)public/fallback-trophy.svg— real data, renders correctlyGITHUB_TOKEN1in 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.