fix(cli): refuse an empty or non-decimal numeric flag value
Merged
GA
1h ago+31+31+01234567890123456789-12-12-01234567890123456789
What
- The numeric flags of
e2e run,e2e mcpande2e exploretake decimal digits only. --retries ""(a variable that is unset),0x1and1e3are a usage error, exit 2, as an empty--tagalready is, never read as some other number.
Why
Number('') is 0, so an unset --retries "$RETRIES" turned retries off in CI without a word.
How it works
integerOfreads/^\d+$/and returns NaN for anything else (packages/e2e/src/cli/index.ts).parsePositiveInt,parseNonNegativeIntandparseBoundedIntcall it instead ofNumber; their bounds and messages are unchanged.- One sentence in
docs/reference/cli.mdx, next to the empty--tagrule.
Issue
Fixes #2488
Verified
Ran it locally: yes
--retries on a test that always fails, with retries: 2 in the config:
| main | this PR | |
|---|---|---|
--retries 2 | 3 attempts | 3 attempts |
--retries "" | 1 attempt, no error | error: option '--retries <n>' argument '' is invalid. must be a nonnegative integer, exit 2 |
--retries 0x1 | 2 attempts | same usage error, exit 2 |
pnpm --filter e2e exec vitest run tests/unit/cli.test.ts: the new cases are '', ' ', 0x1 and 1e1 for --retries and --workers, plus '' and 1e1 for --max-failures and '' and 0x10 for --max-duration. On main, '' for --retries, 1e1 for --max-failures and 0x10 for --max-duration fail; an empty --max-failures or --max-duration was already refused, since 0 is below their minimum. All pass here. pnpm check passes.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.
š¤ Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Numeric options for
e2e run,e2e mcp, ande2e exploreaccept decimal digits only. Empty values, whitespace, signed numbers, hexadecimal values, and scientific notation result in a usage error (exit code 2). - An empty
--reportervalue fore2e runresults in a usage error instead of starting a run without reporters.
- Numeric options for
- Documentation
- Updated the CLI reference to describe numeric-option and reporter validation.