Skip to content

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

Merged
kdy1 merged 2 commits into
e2e-inc:mainfrom
gagarinyury:fix/cli-strict-integer-flags
Nov 30, 2026
Merged

kdy1 merged 2 commits into
e2e-inc:mainfrom
gagarinyury:fix/cli-strict-integer-flags

Conversation

@gagarinyury

@gagarinyury gagarinyury commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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:

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/**/*.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.

Number('') is 0, so `--retries "$RETRIES"` with the variable unset turned
retries off without a word, and `0x1` or `1e3` were taken too. The numeric
flag parsers read decimal digits only; anything else is a usage error,
exit 2, as an empty --tag already is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 29, 2026
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: CLI integer parsing

Layer / File(s) Summary
Integer parsing and validation coverage
packages/e2e/src/cli/index.ts, packages/e2e/tests/unit/cli.test.ts, docs/reference/cli.mdx, .changeset/cli-strict-integer-flags.md
The integer parsers validate decimal digits before conversion and retain their existing safe-integer and range checks. Tests cover empty, whitespace, hexadecimal, and scientific-notation inputs. The reference and changeset document the validation behavior. The reference also states that an empty --reporter value is a usage error.

Suggested reviewers: samanyudas

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 2d331

Numeric CLI flags now reject empty, hexadecimal and exponent values with a usage error and exit code 2, instead of silently treating them as numbers such as 0. The change is small, covered by tests, easy to revert, and no merge-blocking issue was found.

Architecture risk: Medium · up to 3f492

The change affects 2 source areas.

CLI callers must provide decimal-digit strings for numeric flags; when they provide malformed forms such as empty, whitespace, hexadecimal, or exponent notation, the CLI rejects them with a usage error instead of coercing them, while existing range checks still apply.

Changed areas: packages/e2e, docs

Review details

Systems and components

  • observed — packages/e2e (library) was modified; 2 changed files map to changed impact.
  • observed — 1 changed file mapped to docs.

Before / after behavior

  • observed — Modified behavior in packages/e2e/src/cli/index.ts: Added integerOf, which converts only strings matching decimal digits and returns NaN otherwise; parsePositiveInt now uses it instead of Number before applying its existing positive safe-integer check.
  • observed — Modified behavior in packages/e2e/src/cli/index.ts: parseNonNegativeInt now uses integerOf instead of Number; its nonnegative safe-integer validation is unchanged.
  • observed — Modified behavior in packages/e2e/src/cli/index.ts: parseBoundedInt now uses integerOf instead of Number; its safe-integer and inclusive bounds checks are unchanged.
  • observed — Modified behavior in packages/e2e/tests/unit/cli.test.ts: The --max-failures invalid-input cases now also include an empty value and scientific notation.

Reliability and maintainability

  • inferred — Risk-relevant change factors for packages/e2e: blast_radius_3; direct_dependents_3
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6dcbd3bc-6869-4980-98ec-2ee651277285
Commits

Reviewing files that changed from the base of the PR and between 3f492e5 and 2d33144.

Files selected for processing: 1

  • docs/reference/cli.mdx
Files skipped from review as they are similar to previous changes: 1

  • docs/reference/cli.mdx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

View guided diff | Re-trigger cubic

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (AI triage pass), not yet read by a maintainer.

Reviewed 3f492e53b. Root-cause fix for #2488: the three numeric flag parsers now read /^\d+$/ before Number, so '', ' ', +1, 0x1 and 1e1 are usage errors (exit 2) instead of 0 or some other number. Correct and minimal. No must-fixes.

What I checked:

  • Coverage: every numeric flag of run, mcp and explore goes through parsePositiveInt, parseNonNegativeInt or parseBoundedInt (index.ts:62, :76, :109). --shard already used a digit regex. No other Number( reads a flag in src/cli.
  • Real impact is on --retries and --workers (parseNonNegativeInt, main index.ts:67). On main an empty value reads as 0, and the positive and bounded parsers already refuse that because their minimum is 1. Hex and exponent forms got through all three parsers.
  • Built CLI: run --retries '' exits 2 with argument '' is invalid. must be a nonnegative integer. ' ', 0x1, 1e1 and +1 give the same error, and mcp --max-sessions 0x2 names its bounds. 007 and 2 still parse.
  • Tests: tests/unit/cli.test.ts passes (115). With main's index.ts put back, 3 tests fail (1e1 for --max-failures, 0x10 for --max-duration, '' for --retries), so the tests catch the bug.
  • The changeset (e2e patch) and the cli.mdx sentence match the code. Refusing +1 and 0x1 narrows what the CLI accepts, but nobody should depend on those forms.

Nits

  1. cli.mdx:867 "never a 0": 0x1 used to read as 1, not 0. "never read as some other number" covers both cases.
  2. The PR body says the new '' cases for --max-failures and --max-duration fail on main. They pass there, because 0 is below those flags' minimum. Only 1e1 and 0x10 fail for those flags. Body only, the code is fine.

For the maintainer

  • packages/e2e/src/cli/index.ts is already 1258 lines on main, and this PR adds 9. Splitting it is not this PR's job. The numeric parsers could later move next to parse-names.ts, the same way the list parsers were split out.
  • Fork CI (docs, spec, mobile, benchmark, docs translations, review-verdict) is awaiting approval.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 29, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

View guided diff | Re-trigger cubic

@gagarinyury

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both nits are in: 2d33144 reads "never read as some other number" in cli.mdx, and the PR body now says which of the new cases fail on main (an empty --max-failures or --max-duration was already refused).

@gagarinyury

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions

Copy link
Copy Markdown
Contributor

/ready did not add the Ready for Human Review label yet:

  • 6 workflow run(s) waiting for a maintainer to approve them, so CI has not run on the latest commit

Fix these and comment /ready again. How the label works.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (AI triage pass), not yet read by a maintainer.

Reviewed 2d3314471. Delta since 3f492e53b is one docs line: both earlier nits are fixed. No must-fixes; the earlier verdict stands.

  • cli.mdx:867 now reads "never read as some other number", which covers 0x1 reading as 1.
  • The PR body now says only '' for --retries, 1e1 for --max-failures and 0x10 for --max-duration fail on main, which matches what the earlier pass measured.
  • No code changed, so the earlier checks (built CLI exit 2, mutation check with 3 failing tests) still hold. No open review threads.

For the maintainer

  • /ready was refused only because 6 fork workflow runs await maintainer approval (docs, spec, mobile, benchmark, docs translations, review-verdict). Approve them; once green the label can go back on.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 29, 2026

@kdy1 kdy1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This text was drafted with AI and posted after human approval.

  • Harness: T3 Code
  • AI agents: coordinator: Claude Opus 5.5 (claude-opus-5-5), reviewer: GPT-6.2 Astra (gpt-6.2-astra), reviewer: GPT-6.2 Sol (gpt-6.2-sol), reviewer: Claude Opus 5.5 (claude-opus-5-5), reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5)

Verdict: Approve

This review approves the pull request. The P3 items are optional and do not block the merge.

Reviewed commit: 2d33144719ddac3a378c861c1c992d6f6781420a

  • P3 (non-blocking): 1 (1 inline)

Comment thread docs/reference/cli.mdx
Comment on lines +864 to +867
with no reporters. A numeric flag (`--retries`, `--workers`,
`--max-failures`, a timeout) takes decimal digits only: an empty value
(`--retries "$RETRIES"` with the variable unset), `0x1`, or `1e3` is the same
usage error, never read as some other number.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 · Non-blocking · The decimal-digits rule is documented for e2e run only

Optional. This does not block the merge.

The new sentence is in the e2e run section, but the changeset says that the e2e mcp and e2e explore numeric flags changed too. These pages describe the affected flags and still give only their ranges:

  • docs/reference/mcp.mdx:69 (--max-sessions): --max-sessions 0x2 now exits 2 instead of starting with 2 sessions.
  • The e2e explore option table, docs/reference/cli.mdx:1253-1254 (--max-steps, --timeout): --timeout 6e5 now exits 2.
  • skills/e2e/references/running.md:44-47 says that an empty --target or --tag exits 2 and gives --retries guidance, but does not say that an empty --retries "$RETRIES" now exits 2.

AGENTS.md requires the matching docs page and skills/e2e/ to change with the behavior. Non-blocking.

@kdy1
kdy1 added this pull request to the merge queue Nov 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2026
@kdy1
kdy1 added this pull request to the merge queue Nov 30, 2026
Merged via the queue into e2e-inc:main with commit eb5b5f9 Nov 30, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

e2e run --retries "" reads as 0 and turns retries off instead of failing

3 participants