Skip to content

Commit ea059a6

Browse files
authored
test(validation): check query validation boundaries for user max length (JhaSourav07#1887)
## Description Fixes JhaSourav07#1452 Program: GSSoC 2026 This PR handles the implementation of edge validation boundary unit tests for the incoming `?user=` query parameters. Previously, basic existence formatting was evaluated, but precise length bounds were missing test coverage. This patch checks constraint robustness against long string payloads. ### Changes Made * Added 1 specific schema validation boundary test case inside `lib/validations.test.ts`. * Mocked a boundary payload passing a username input string length of 40 characters using `'a'.repeat(40)`. * Asserted that validation handles the error structure and responds exactly with the boundary constraint message: `'cannot exceed 39 characters'`. ### Why this matters Secures internal endpoint ingestion routers from parsing massive string parameters, mitigating resource exploitation vectors or unexpected error bubble-ups down the call stack during upstream fetching operations. --- ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) --- ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`npm run test`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [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 "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.
2 parents 10a1634 + 5549f70 commit ea059a6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ describe('streakParamsSchema', () => {
252252
}
253253
});
254254

255+
it('should reject user values longer than 39 characters', () => {
256+
const result = streakParamsSchema.safeParse({
257+
user: 'a'.repeat(40),
258+
});
259+
260+
expect(result.success).toBe(false);
261+
if (!result.success) {
262+
expect(result.error.issues[0]?.message).toContain('cannot exceed 39 characters');
263+
}
264+
});
265+
255266
it('should fail when user is whitespace-only input', () => {
256267
const result = streakParamsSchema.safeParse({
257268
user: ' ',

0 commit comments

Comments
 (0)