Repository navigation
fix(cli): refuse an empty or non-decimal numeric flag value - #2492
Conversation
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>
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
okwasniewski
left a comment
There was a problem hiding this comment.
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,mcpandexploregoes throughparsePositiveInt,parseNonNegativeIntorparseBoundedInt(index.ts:62, :76, :109).--shardalready used a digit regex. No otherNumber(reads a flag insrc/cli. - Real impact is on
--retriesand--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 withargument '' is invalid. must be a nonnegative integer.' ',0x1,1e1and+1give the same error, andmcp --max-sessions 0x2names its bounds.007and2still parse. - Tests:
tests/unit/cli.test.tspasses (115). With main'sindex.tsput back, 3 tests fail (1e1for--max-failures,0x10for--max-duration,''for--retries), so the tests catch the bug. - The changeset (
e2epatch) and thecli.mdxsentence match the code. Refusing+1and0x1narrows what the CLI accepts, but nobody should depend on those forms.
Nits
- cli.mdx:867 "never a 0":
0x1used to read as 1, not 0. "never read as some other number" covers both cases. - The PR body says the new
''cases for--max-failuresand--max-durationfail on main. They pass there, because 0 is below those flags' minimum. Only1e1and0x10fail for those flags. Body only, the code is fine.
For the maintainer
packages/e2e/src/cli/index.tsis 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 toparse-names.ts, the same way the list parsers were split out.- Fork CI (docs, spec, mobile, benchmark, docs translations, review-verdict) is awaiting approval.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Both nits are in: 2d33144 reads "never read as some other number" in |
|
/ready |
|
Fix these and comment |
okwasniewski
left a comment
There was a problem hiding this comment.
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
0x1reading as 1. - The PR body now says only
''for--retries,1e1for--max-failuresand0x10for--max-durationfail 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
/readywas 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.
kdy1
left a comment
There was a problem hiding this comment.
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)
| 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. |
There was a problem hiding this comment.
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 0x2now exits 2 instead of starting with 2 sessions.- The
e2e exploreoption table,docs/reference/cli.mdx:1253-1254(--max-steps,--timeout):--timeout 6e5now exits 2. skills/e2e/references/running.md:44-47says that an empty--targetor--tagexits 2 and gives--retriesguidance, 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.
What
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('')is0, 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.docs/reference/cli.mdx, next to the empty--tagrule.Issue
Fixes #2488
Verified
Ran it locally: yes
--retrieson a test that always fails, withretries: 2in the config:--retries 2--retries ""error: option '--retries <n>' argument '' is invalid. must be a nonnegative integer, exit 2--retries 0x1pnpm --filter e2e exec vitest run tests/unit/cli.test.ts: the new cases are'',' ',0x1and1e1for--retriesand--workers, plus''and1e1for--max-failuresand''and0x10for--max-duration. On main,''for--retries,1e1for--max-failuresand0x10for--max-durationfail; an empty--max-failuresor--max-durationwas already refused, since 0 is below their minimum. All pass here.pnpm checkpasses.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.🤖 Generated with Claude Code
Summary by CodeRabbit
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).--reportervalue fore2e runresults in a usage error instead of starting a run without reporters.