fix(cli): refuse an empty or non-decimal numeric flag value

Merged
GA
1h ago
+31-12

What

  • The numeric flags of e2e run, e2e mcp and e2e explore take decimal digits only.
  • --retries "" (a variable that is unset), 0x1 and 1e3 are a usage error, exit 2, as an empty --tag already 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

  1. integerOf reads /^\d+$/ and returns NaN for anything else (packages/e2e/src/cli/index.ts). parsePositiveInt, parseNonNegativeInt and parseBoundedInt call it instead of Number; their bounds and messages are unchanged.
  2. One sentence in docs/reference/cli.mdx, next to the empty --tag rule.

Issue

Fixes #2488

Verified

Ran it locally: yes

--retries on a test that always fails, with retries: 2 in the config:

mainthis PR
--retries 23 attempts3 attempts
--retries ""1 attempt, no errorerror: option '--retries <n>' argument '' is invalid. must be a nonnegative integer, exit 2
--retries 0x12 attemptssame 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/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

šŸ¤– Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Numeric options for e2e run, e2e mcp, and e2e explore accept decimal digits only. Empty values, whitespace, signed numbers, hexadecimal values, and scientific notation result in a usage error (exit code 2).
    • An empty --reporter value for e2e run results in a usage error instead of starting a run without reporters.
  • Documentation
    • Updated the CLI reference to describe numeric-option and reporter validation.