Fix API: Validate and Clamp Grace Parameter in calculateStreak Function - #8356
Fix API: Validate and Clamp Grace Parameter in calculateStreak Function#8356tamilr0727-ux wants to merge 1 commit into
Conversation
|
@tamilr0727-ux is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This PR addresses the validation of the |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
Grace parameter validation and clamping is a necessary fix — the parsedGrace/numericGrace/safeGrace chain correctly handles edge cases. The CI is failing though, please investigate.
Labels: level:beginner (1 file, focused fix), quality:clean, type:bug, mentor:Aamod007
Aamod007
left a comment
There was a problem hiding this comment.
Re-reviewing after noting the only CI failure is Vercel authorization (not code-related). All other checks (Format · Lint · Typecheck · Test, Production Build, CodeQL) pass. Approving — the Vercel deploy auth is a repo-level config issue, not a code problem.
Description
Fixes validation for the
graceparameter incalculateStreak()by enforcing the documented range of 0–7 before the value is used in streak calculations.Changes
Problem Addressed
Previously,
calculateStreak()accepted arbitrary grace values without validation, resulting in behavior that differed from the documentation. Invalid values such as excessively large numbers, negative values, or non-numeric inputs could produce inconsistent results.This update guarantees that the function always operates with a valid grace value within the supported range.
Validation
Implemented tests covering:
Verification
Fixes #6739
Pillar
Visual Preview
Can Check in the Files Changed Section.
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.