Skip to content

test(validation): check query validation boundaries for grace param#1949

Open
ashishraj1504 wants to merge 1 commit into
JhaSourav07:mainfrom
ashishraj1504:fix/grace-validation-boundaries
Open

test(validation): check query validation boundaries for grace param#1949
ashishraj1504 wants to merge 1 commit into
JhaSourav07:mainfrom
ashishraj1504:fix/grace-validation-boundaries

Conversation

@ashishraj1504
Copy link
Copy Markdown
Contributor

Description

Fixes #1446
Program: GSSoC 2026

This PR handles the implementation of validation boundary unit testing for the incoming ?grace= query parameter under variation 3.

Previously, normal boundary parameters were evaluated, but passing negative value integers required isolated boundary test coverage to guarantee input schema safety.

Changes Made

  • Added 1 target schema validation boundary test case inside lib/validations.test.ts.
  • Mocked an invalid parameter payload passing a negative grace value set to -1.
  • Asserted that the system validation layer catches the negative range violation and handles it appropriately according to the repository's parsing constraints.

Why this matters

Secures internal endpoint ingestion routers from processing out-of-bound integer configurations, ensuring the streak engine is protected against faulty date calculation offsets or logic errors down the call stack.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (npm run test).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • 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.
  • I have starred the repo.
  • 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 (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.

Copilot AI review requested due to automatic review settings May 31, 2026 04:59
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 31, 2026

@ashishraj1504 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a test verifying that streakParamsSchema sanitizes a negative grace input to 0 when parsed via safeParse.

Changes:

  • New test case for negative grace value handled through safeParse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/validations.test.ts Outdated
Comment on lines +21 to +32
it('sanitizes negative grace input when parsed through the schema', () => {
const result = streakParamsSchema.safeParse({
user: 'octocat',
grace: '-1',
});

expect(result.success).toBe(true);

if (result.success) {
expect(result.data.grace).toBe(0);
}
});
Copy link
Copy Markdown
Collaborator

@Aamod007 Aamod007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test duplicates the existing clamps "-1" to 0 at line 17. Both test grace: '-1' and assert it clamps to 0. The only difference is using safeParse vs the parse() helper — no new coverage is added.

Please either remove this test or add a boundary case that isn't already covered (e.g., testing grace: '0' via safeParse, or testing a negative non-integer value).

@ashishraj1504 ashishraj1504 force-pushed the fix/grace-validation-boundaries branch from 698cccf to cdf8d4e Compare May 31, 2026 06:29
@ashishraj1504
Copy link
Copy Markdown
Contributor Author

@Aamod007 , Thank you for the guidance! You're completely right—the third test case duplicated line 17.

I have removed that duplicate block entirely, keeping only the new non-integer boundary case ('-1.5'). The file is fully cleaned up, all 95+ tests are passing green locally, and I've force-pushed the clean commit. Ready for another look!

@ashishraj1504 ashishraj1504 requested a review from Aamod007 May 31, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(api validation): check query validation boundaries for ?grace= parameter (Variation 3)

3 participants