Skip to content

[GSSoC'26] fix(batch): return unknown for malformed expiry dates#1803

Merged
dipexplorer merged 3 commits into
RatLoopz:mainfrom
vipul674:1799-fix-expiry-status-validation
Jun 15, 2026
Merged

[GSSoC'26] fix(batch): return unknown for malformed expiry dates#1803
dipexplorer merged 3 commits into
RatLoopz:mainfrom
vipul674:1799-fix-expiry-status-validation

Conversation

@vipul674

Copy link
Copy Markdown
Contributor

Description

  • getExpiryStatus() did not check for NaN after new Date(expiryDate), causing malformed expiry dates (e.g. "N/A", "invalid") to fall through to "green" instead of "unknown".
  • Added isNaN(expiry.getTime()) guard that returns "unknown" for unparseable dates.

Files Changed

  • apps/api/src/routes/batch.ts: Added NaN check after date parsing in getExpiryStatus
  • apps/api/tests/batch.test.ts: Added 5 tests covering null, malformed, expired, near-expiry, and future expiry dates

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation

Difficulty & Label Request

Assessed difficulty: level1

Please apply the matching difficulty label so the contribution is scored correctly for GSSoC '26.

If applicable, please also apply gssoc:approved after review.

Testing & Verification

Commands run:

npx jest tests/batch.test.ts

Result:

Tests:       12 passed, 12 total

Known Limitations

  • None

GSSoC 2026 Compliance

This contribution was prepared with AI assistance and manually reviewed before submission.

Closes #1799

@vipul674

Copy link
Copy Markdown
Contributor Author

Report for Issue #1799

Bug

getExpiryStatus() falls through to "green" when malformed expiry dates result in NaN from new Date().

Changes

  • Added isNaN(expiry.getTime()) check → returns "unknown"
  • 5 tests: null, malformed, expired, near-expiry, future dates

Files Changed

  1. apps/api/src/routes/batch.ts — 1 line added

Verification

  • Malformed dates → "unknown" (was "green")
  • Valid dates → unchanged behavior
  • All 12 batch tests pass

@RatLoopz Please review!

@dipexplorer

Copy link
Copy Markdown
Member

Hey @vipul674, your PR description says u added 5 tests to apps/api/tests/batch.test.ts, but that file isn't included in your commit! It looks like you just forgot to git add the test file before committing and pushing.

Could u plz commit and push that missing test file to this branch? Once the tests are in, I'll happily merge this!

null expiry_date, malformed date, expired, near-expiry, and future date.
Closes RatLoopz#1799
@vipul674

Copy link
Copy Markdown
Contributor Author

Hey @dipexplorer! The missing test file apps/api/tests/batch.test.ts has been added with 5 expiry status test cases (null, malformed, expired, near-expiry, future dates). The commit includes all the tests mentioned in the PR description.

@RatLoopz, CI should re-run now that the test file is present.

⚠️ Note: Vercel deployment is blocked by an external auth requirement — this is a pre-existing repo config issue ("Authorization required to deploy"). The actual code and test changes are complete.

@dipexplorer dipexplorer added level:intermediate 35 pts quality:exceptional multiplier x1.5 type:bug Something isn't working type:testing Unit tests, integration tests labels Jun 15, 2026
@dipexplorer dipexplorer merged commit 321aa4f into RatLoopz:main Jun 15, 2026
21 of 24 checks passed
@github-project-automation github-project-automation Bot moved this from 📥 Backlog to 🎉 Merged in SahiDawa Workflow Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @vipul674! Your Pull Request "[GSSoC'26] fix(batch): return unknown for malformed expiry dates" has been successfully merged by @dipexplorer.

Thank you for your valuable contribution to SahiDawa! 🇮🇳
If this was for GSSoC 2026, your work is officially merged and valid. Keep up the great work and feel free to claim other open issues. 🚀

Follow us on LinkedIn: https://www.linkedin.com/company/ratloopz/ to get shoutout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for gssoc level:intermediate 35 pts quality:exceptional multiplier x1.5 type:bug Something isn't working type:testing Unit tests, integration tests

Projects

Status: 🎉 Merged

Development

Successfully merging this pull request may close these issues.

[BUG] Malformed expiry dates are marked green in batch traceability

2 participants