Skip to content

fix: return friendly SVG for invalid GitHub username#7956

Open
SahilSolve02 wants to merge 1 commit into
JhaSourav07:mainfrom
SahilSolve02:feature/fix-invalid-username-error
Open

fix: return friendly SVG for invalid GitHub username#7956
SahilSolve02 wants to merge 1 commit into
JhaSourav07:mainfrom
SahilSolve02:feature/fix-invalid-username-error

Conversation

@SahilSolve02

Copy link
Copy Markdown

Bug Fixed

Fixes #7951 - Invalid GitHub username returned 500 error

Changes

  • Wrapped fetch logic in try-catch in app/api/streak/route.ts
  • Returns HTTP 200 with dark SVG error card for invalid usernames
  • SVG displays "User not found or private account"

Files Changed

  • app/api/streak/route.ts only

Checklist

  • Only modified app/api/streak/route.ts
  • No other files touched
  • No existing code deleted

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@SahilSolve02 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @SahilSolve02, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@SahilSolve02 SahilSolve02 force-pushed the feature/fix-invalid-username-error branch from 6bfdad4 to be0f4ac Compare July 11, 2026 05:51
@Aamod007

Copy link
Copy Markdown
Collaborator

@SahilSolve02

Hey, I took a look at your PR #7956 and the 8 CI failures. The root issue is that your change wraps the fetch logic in a try-catch and returns HTTP 200 with an SVG error card for invalid usernames, but the existing test suite expects specific error status codes — 404 for not-found users, 429 for rate limits, 500 for server errors — along with matching cache headers like no-cache and no-store. When you return 200 instead, all those assertions break.

The good news is the codebase already handles this exactly the way the issue describes. If you look at route.ts around lines 841-857, there's already a generateNotFoundSVG() call that returns a friendly SVG error card with a 404 status. The reason it uses 404 and not 200 is intentional — since these SVGs are embedded in READMEs via tags, the browser renders the SVG body regardless of the HTTP status code, so the user still sees the nice error card. But keeping the proper status code prevents CDNs from caching the error as if it were a successful response, which would mean the error gets stuck and never retries.

So the fix is to not change the status codes or cache headers at all. If the SVG error card itself needs a design update (like making it darker or changing the text), that should be done inside generateNotFoundSVG() in lib/svg/generator.ts. I'd also recommend running npx vitest run app/api/streak/route.test.ts locally before pushing — that'll catch these failures immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:blocked This PR is blocked due to a failing CI check.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Invalid GitHub Username Returns 500 Error Instead of Friendly Message

2 participants