Repository navigation
fix(cli): reject empty and non-decimal text for integer positional arguments - #4182
arjunprabhulal wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryThe PR adds
arjunprabhulal acknowledged that malformed Reviews (1) · Last reviewed commit: "fix(cli): reject empty and non-decimal t..." · Reviewed by Greptile |
Validate decimal tokens at the CLI owner before safe-number parsing. Apply the same rule to positional indexes/generations and repeated record selectors, retaining leading-zero decimals and canonical MCP inputs. Refs #4182 Co-authored-by: Arjun Prabhulal <[email protected]>
|
Integrated on main in 8d82579. CLI integer arguments now validate decimal token syntax before safe-number coercion, across generations, script positions and repeated record selectors. Leading-zero decimal inputs remain supported; MCP number contracts and hex entry points retain their existing semantics. Public CLI negatives cover empty/whitespace, alternate numeric syntax, unsafe integers and an invalid later repeated selector. The Cutter bridge control confirms 000 selects generation 0. Relevant positive CLI/MCP workflows and main CI passed: https://github.com/morluto/rea/actions/runs/38792163880. Closing as addressed. |
Summary
Integer CLI arguments accept text that is not a number.
rea cutter-command <session> "$GEN" pdiwithGENunset sendsexpected_generation: 0, and a fresh Cutter bridge is at generation 0, so the stale-document guard passes without the caller ever supplying a generation.rea trace-web-module-imports <manifest> ""likewise traces script 0 and exits 0. Hex, binary, exponent, signed and fractional spellings (0x1,0b1,1e0,+1,1.0) are also accepted.Problem and expected behavior
These arguments were declared as
z.coerce.number().int().nonnegative()(or.min(0)/.min(1)).z.coerce.number()callsNumber(value), andNumber("")andNumber(" ")are0, which passes both checks. Incur passes an empty token through as a positional, so the empty value reaches the schema. Expected: anything other than a plain decimal integer is aVALIDATION_ERRORnaming the argument, as it already is for other malformed positionals. MCP is unaffected because its schemas use strictz.number().Change and scope
src/cli/options.tsaddscliIntegerArgument(min): a string that must match^(?:0|[1-9][0-9]*)$, piped intoz.coerce.number<string>().int().safe().min(min). A pipe keeps the schema exportable, which a transform would not. It replaces the coerced schemas at every CLI integer site:cutter-commandexpectedGeneration,trace-web-module-importsscriptIndex, the web source-locationscriptIndex,line(min 1) andcolumn, and the web network capture--recordordinals. Valid decimal values parse to the same numbers as before. Not included: MCP schemas, which already reject strings.Contract and boundary impact
Semantic owner and earliest changed stage: CLI argument parsing (
src/cli/*Commands.ts,src/cli/options.ts).Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
CLI and MCP/tool-catalog contract: CLI rejects inputs it previously coerced to numbers; accepted values are unchanged. MCP unchanged.
Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details (if applicable):
cutter-commandno longer runs against session generation 0 when the generation argument is empty.Generated metadata (
docs/public/product-catalog.json), package, or installation impact: none committed; CI regenerates catalogs.Documentation or usability only; no target interaction.
Evidence and regression coverage
tests/boundary/cli/cliIntegerArguments.test.tsrunscutter-commandandtrace-web-module-importswith""," ",0x1,0b1,1e0,+1and1.0, and expects exit 1 with aVALIDATION_ERRORonexpectedGeneration/scriptIndex.mainall 14 cases exit 0 (executed).{"code":"VALIDATION_ERROR","fieldErrors":[{"path":"expectedGeneration","message":"Expected a decimal integer",...}]}.--recordis covered by the shared schema but has no dedicated case.Validation performed
npm run test:prepare && npx vitest run --project cli-boundary— 88 files, 498 passed, 2 skippednpx vitest run --project mcp-boundary— 138 files, 776 passed, 5 skippednpx vitest run tests/acceptance/webModuleCli.test.ts— 1 passednpx tsc --noEmit -p .— no errorsnpx prettier --checkandnpx oxlinton the changed files — clean apart from the existingmax-paramswarning atoptions.ts:69