fix(api): clamp days query param in hourly contributions route#2235
Open
Honey-pg wants to merge 4 commits into
Open
fix(api): clamp days query param in hourly contributions route#2235Honey-pg wants to merge 4 commits into
Honey-pg wants to merge 4 commits into
Conversation
Parse days as integer and clamp to 1..365, matching other metrics routes and preventing malformed input from causing 502 errors.
|
@Honey-pg is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Replace page.evaluate fetch on about:blank with Playwright request + session cookie so relative API URLs resolve. Assert authenticated access returns JSON instead of requiring GitHub 200 with mock token.
The Playwright api.spec.ts fix belongs on security/x-dns-prefetch-control-on, not this branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Parse
daysas an integer and clamp to 1..365 inGET /api/metrics/contributions/hourly, matching other metrics routes and preventing malformed input (negatives, fractions,Infinity, huge values) from producing invalid date windows or 502 errors.#Closed #2193
Type of Change
Changes Made
Number()parsing withparseInt+ default/clamp logic insrc/app/api/metrics/contributions/hourly/route.tstest/contributions-hourly.test.tscovering negative, fractional, zero, unbounded, and missingdaysinputsHow to Test
npm run type-checknpx vitest run test/contributions-hourly.test.tsdays:?days=-30→days: 1?days=Infinity→days: 30?days=999999→days: 365days: 30Checklist
npm run lintpasses locallynpm run type-check)Additional Notes
Aligns with the existing validation pattern in
contributions/route.ts,repos/route.ts, andproductive-hours/route.ts. Hourly contributions keeps its default of 30 days when the param is missing or invalid.