Skip to content

fix: reject non-integer --limit values in list commands - #424

Open
RaphaelFakhri wants to merge 1 commit into
resend:mainfrom
RaphaelFakhri:fix/strict-limit-parsing
Open

RaphaelFakhri wants to merge 1 commit into
resend:mainfrom
RaphaelFakhri:fix/strict-limit-parsing

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

parseLimitOpt reads --limit with parseInt, which keeps the leading digits and drops the rest. Every list command uses it, so a value that is not an integer between 1 and 100 is sent as a different number, with exit code 0, even though the error message says --limit must be an integer between 1 and 100.

input sent as limit on main
2.5 2
25abc 25
1,000 1

Repro against a local mock of the API:

RESEND_BASE_URL=http://127.0.0.1:4599 RESEND_API_KEY=re_test \
  resend emails list --limit 2.5 --json

On main the mock receives GET /emails?limit=2 and the command exits 0. With this change the command returns invalid_limit, exits 1 and sends nothing. --limit 25 still sends limit=25.

Change

parseLimitOpt parses the whole string with Number and requires Number.isInteger, keeping the existing 1-100 range check, error message and error code. Empty input is still rejected (Number('') is 0).

Tests

Added parseLimitOpt cases to tests/lib/pagination.test.ts: 1, 10 and 100 are accepted, and 0, 101, '', abc, 2.5, 25abc and 1,000 return invalid_limit. The 2.5, 25abc and 1,000 cases fail on main and pass with this change.

Ran pnpm test (1478 passed, 1 skipped), pnpm lint and pnpm typecheck.

Fixes #423

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Oct 28, 2026

This branch has not been deployed

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

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--limit accepts non-integer values and sends a truncated number

1 participant