Skip to content

fix(api): guard out-of-range numeric since on /api/pulls#234

Open
jaso0n0818 wants to merge 1 commit into
MkDev11:mainfrom
jaso0n0818:fix/pulls-since-rangeerror
Open

fix(api): guard out-of-range numeric since on /api/pulls#234
jaso0n0818 wants to merge 1 commit into
MkDev11:mainfrom
jaso0n0818:fix/pulls-since-rangeerror

Conversation

@jaso0n0818

Copy link
Copy Markdown

Summary

/api/pulls?since=... could crash with an unhandled RangeError on a malformed since value. parseSinceIso took the numeric branch for any finite since > 0 and called new Date(sinceMs).toISOString() without validating the result. A finite but out-of-range epoch (e.g. ?since=1e21, or a 20-digit integer) produces an Invalid Date, and Date.prototype.toISOString() throws RangeError: Invalid time value on it — so the route returned a 500 instead of treating it as a bad filter.

The date-string branch right below already guards with Number.isFinite(sinceDate.getTime()); this applies the same guard to the numeric branch, so an out-of-range since falls through to null (no filter), consistent with how other malformed input is handled.

Related Issues

No issue; small input-robustness fix in the same vein as the existing malformed-input handling.

Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Other (describe):

Testing

  • pnpm build passes
  • Manual browser smoke test (for UI changes)
  • N/A — API-only change

Ran from the repo root (Node 22, pnpm 10):

pnpm run lint   # clean, --max-warnings=0
pnpm build      # next build succeeds

Reproduced the bug and confirmed the fix against the isolated parseSinceIso logic:

before:  ?since=1e21                  -> throws RangeError: Invalid time value (500)
         ?since=99999999999999999999  -> throws RangeError (500)
after:   ?since=1e21                  -> null  (treated as no since-filter)
         ?since=99999999999999999999  -> null
         ?since=1700000000000         -> 2023-11-14T22:13:20.000Z  (unchanged)
         ?since=2026-06-01            -> 2026-06-01T00:00:00.000Z  (unchanged)
         ?since=not-a-date            -> null  (unchanged)

Checklist

  • Self-reviewed the diff
  • Follows existing code patterns and naming
  • No unrelated changes included
  • Documentation updated if behavior changed

parseSinceIso took the numeric branch for any finite `since > 0` and called
new Date(sinceMs).toISOString() without validating the result. A finite but
out-of-range epoch (e.g. ?since=1e21 or a 20-digit integer) produces an Invalid
Date, and Date.prototype.toISOString() throws RangeError on it, so the request
crashed with an unhandled 500 instead of being treated as a malformed filter.

Validate the millisecond date before formatting, mirroring the guard already
applied to the date-string branch, so an out-of-range `since` falls through to
null (no filter) like other malformed input.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jaso0n0818, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 4 minutes and 43 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d791cf84-d3de-454b-a170-379252bef642

📥 Commits

Reviewing files that changed from the base of the PR and between f9fb312 and 64de80f.

📒 Files selected for processing (1)
  • src/app/api/pulls/route.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant