Skip to content

fix(api): classify compare route GitHub errors#2205

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
eshaanag:fix/compare-route-error-statuses
Jun 1, 2026
Merged

fix(api): classify compare route GitHub errors#2205
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
eshaanag:fix/compare-route-error-statuses

Conversation

@eshaanag
Copy link
Copy Markdown
Contributor

@eshaanag eshaanag commented Jun 1, 2026

Description

Fixes #2204

Pillar

  • 🛠️ Other (Bug fix, refactoring, docs)

What changed

The /api/compare route used Promise.allSettled, but both rejected fetch branches returned 404 unconditionally. That made GitHub rate limits and upstream failures look like missing users.

This PR adds a small helper that classifies rejected GitHub dashboard fetches before responding:

  • not-found / could-not-resolve errors still return 404
  • rate-limit style errors return 403 with the existing GitHub rate-limit message
  • other upstream failures return 500 instead of being mislabeled as not-found

Tests were added for user1 rate-limit, user2 rate-limit, and a non-rate-limit upstream failure.

Visual Preview

N/A - JSON API status-code fix only.

Local verification

  • npm run test -- app/api/compare/route.test.ts passed
  • npm run format:check passed
  • npm run lint passed with one existing warning in components/WallOfLove.tsx
  • npm run typecheck passed
  • npm run test passed: 83 files, 1438 passed, 1 expected fail
  • npm run build fails locally with an opaque webpack error; this appears environment/upstream-local because CI build passed on the prior PR after the same local failure pattern

GSSoC 2026

This is raised and fixed under GSSoC 2026. Please add the relevant GSSoC/level labels if they do not sync from the issue automatically.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format / npm run format:check and npm run lint locally.
  • I have run npm run test and all tests pass locally.
  • My commits follow the Conventional Commits format.
  • I have updated README.md if I added a new theme or URL parameter.
  • I have starred the repo.
  • I have made sure that I have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse quality standard.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 1, 2026

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

A member of the Team first needs to authorize it.

@eshaanag
Copy link
Copy Markdown
Contributor Author

eshaanag commented Jun 1, 2026

/addlabel bug api gssoc26

@Aamod007 Aamod007 added GSSoC 2026 mentor:Aamod007 type:bug Something isn't working as expected level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Jun 1, 2026
@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 1, 2026
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 1, 2026
@JhaSourav07 JhaSourav07 merged commit 302f1f3 into JhaSourav07:main Jun 1, 2026
11 of 12 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🎉 Congratulations @eshaanag! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

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

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /api/compare returns 404 for GitHub rate-limit and upstream errors

3 participants