Repository navigation
fix(cli): reject non-decimal integer tokens on every numeric option - #9178
Conversation
Incur coerced z.number() argv with Number(), so 0x10 became 16 and 1e3 became 1000. Decimal tokens now pipe into the domain field, which still owns bounds, defaults, and help.
Codex Review Summary: ❌ FailedThis 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. |
[High impact] The PR appears safe to merge; the previous coverage gap is fixed and no new actionable issues were found. SummaryThe PR makes numeric CLI options reject non-decimal text through
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Numeric CLI text] --> B{Decimal digits only?}
B -->|No| C[Reject before handler]
B -->|Yes| D[Convert to number]
D --> E[Check domain bounds]
F[Omitted option] --> G[Keep domain default or omission]
E --> H[Command handler]
G --> H
Reviews (2) · Last reviewed commit: "test(cli): require the decimal catalog t..." · Reviewed by Greptile |
The catalog loop only failed when a probed field misbehaved, so a registration change could skip every numeric field and still pass. Record each probed command and field and require the known limits.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Numeric CLI options admitted
0x10as 16 and1e3as 1000 because Incur runsNumber()onz.number()argv fields. Decimal tokens now go throughcliDecimalField, which pipes/^[0-9]+$/text into the domain field. That field still owns bounds, defaults, and help.--schemapublishes the input view, so the lexical guard is visible to Ajv.This supersedes the open symptom PRs #8386, #9166, #9168, #9169, #9059, #9038, #5544, and #9161. Those PRs are not merged here.
Problem and expected behavior
Smallest trigger: a numeric option such as
--observation-ms 0x10or--token-limit 1e3. Previously the token was coerced and the command continued with a different number. Empty text on a minimum of 0 could become 0.Expected:
0x10,1e3, blank text, and surrounding spaces are refused during argument parsing. An in-range decimal still parses. Leading zeros stay decimal (010is 10). Omission still uses the domain default.Change and scope
cliDecimalFieldaccepts required, optional, defaulted, nullable, andz.int()domain fields. It does not restate a maximum. Call sites that still built a rawz.number()or passed a domain number straight to Incur now use the helper, including native limits, ADB logcat count/pid, signal and packet page sizes, SQLite row limits, web and JavaScript observation windows, screenshotchannelThreshold, decompile-directorylimit, firmware ranges, desktop capture limits, API-contract file bytes, and Frida duration/keepalive. Frida attach targets are admitted only when they match/^[0-9]+$/and are a positive safe integer.--token-limitand--token-offsetuse the same token check outside registered options.Contribution scope: ordinary fix inside the existing CLI admission boundary. Maintainer scope decision for new providers or target execution: not applicable.
Not included: absolute-path schema parity, CLI/domain path field parity, and the held work listed in the request (desktop stack, debugger throws, host-effect table, Stream D, god-file splits, new settings).
Contract and boundary impact
--schemafor these options isanyOfan integer branch with the domain bounds and a^[0-9]+$string branch. JSON numbers remain valid. MCP tool schemas are unchanged.docs/public/product-catalog.json), package, or installation impact: none. CI generates ignored catalogs.Evidence and regression coverage
tests/boundary/cli/cliDecimalArguments.test.tswalks every registered command withcreateCliandvisitRegisteredCommands. For every integer or number property, Ajv on the advertised schema and IncurParser.parseboth reject0x10and1e3, and an in-range decimal parses. Observation-duration, token-window, and existing integer-argument tests were updated.Parser.coerce, which callsNumber()only when the unwrapped field constructor isZodNumber. The catalog test fails on that path before this change.VALIDATION_ERRORnaming the field, withExpected a decimal integer, before target access.Boundary regression covered: CLI input admission (
docs/testing.mdboundary regressions) for malformed numeric tokens across registered commands. Lifecycle regressions are not applicable; no process or cleanup stage changed.Validation performed
npm run test:focused -- tests/boundary/cli/cliDecimalArguments.test.ts src/cliObservationOptions.test.ts tests/boundary/cli/cliOutput.test.ts— 84 passed.npm run test:focused -- tests/boundary/cli/cliInputSchemaRequired.test.ts— 23 passed.npm run test:focused -- tests/boundary/cli/cliIntegerArguments.test.ts— 111 passed.npx vitest run tests/acceptance/browser/observationDurationCli.test.ts tests/acceptance/webRuntimeCli.test.ts -t advertises— 2 passed.read-bytesoptions.lengthandinstrument-with-fridaoptions.durationMs.npm run test:focused -- tests/boundary/cli/cliDecimalArguments.test.tspassed after that assertion.npm run check:fastpassed.npm run check:fast— typecheck and lint passed. Pre-pushcheck:fastpassed again.npx oxfmton the touched files — formatted.Compatibility, safety, and release
!orBREAKING CHANGEmarker.Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.