Commit 302f1f3
authored
fix(api): classify compare route GitHub errors (JhaSourav07#2205)
## Description
Fixes JhaSourav07#2204
## Pillar
- [x] 🛠️ 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:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` / `npm run format:check` and `npm run
lint` locally.
- [x] I have run `npm run test` and all tests pass locally.
- [x] My commits follow the Conventional Commits format.
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have starred the repo.
- [x] I have made sure that I have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse quality standard.2 files changed
Lines changed: 68 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
93 | 127 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
7 | 39 | | |
8 | 40 | | |
9 | 41 | | |
| |||
26 | 58 | | |
27 | 59 | | |
28 | 60 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 61 | + | |
35 | 62 | | |
36 | 63 | | |
37 | 64 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 65 | + | |
44 | 66 | | |
45 | 67 | | |
46 | 68 | | |
| |||
0 commit comments