Commit c01f36d
authored
fix(api): validate GitHub usernames before downstream API requests (JhaSourav07#1852)
## Description
Fixes JhaSourav07#1782
This PR fixes an issue where the `/api/github` endpoint accepted
malformed GitHub usernames and allowed them to reach the GitHub API
layer, resulting in downstream fetch errors instead of validation
failures.
### Changes Made
* Added GitHub username validation to `githubParamsSchema`
* Rejects usernames containing invalid characters
* Rejects whitespace-only usernames
* Rejects usernames exceeding GitHub's maximum length limit
* Added regression tests covering all of the above scenarios
### Validation
Verified that invalid usernames now return a `400 Bad Request` response
during request validation rather than triggering downstream GitHub API
errors.
## Pillar
* [ ] 🎨 Pillar 1 — New Theme Design
* [ ] 📐 Pillar 2 — Geometric SVG Improvement
* [ ] 🕐 Pillar 3 — Timezone Logic Optimization
* [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
N/A (API validation bug fix)
## Checklist before requesting a review:
* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/github?username=octocat` and invalid username
cases).
* [x] I have run `npm run lint` locally and resolved all errors related
to my changes.
* [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
* [ ] 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.
* [ ] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (not applicable).
* [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
33 | 40 | | |
34 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
35 | 64 | | |
36 | 65 | | |
37 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| |||
0 commit comments