Skip to content

cli: check silently replaces invalid --samples/--max-issues/--tolerance with defaults instead of exiting 2 #7672

Closed

Description

@jrusso1020

hyperframes check rejects a bad --range with exit code 2 (a usage error). Several of its numeric flags don't, though. An invalid value is silently replaced with the default, so the run looks fine but used different settings than the user asked for:

Flag Example What happens today
--samples --samples 0, --samples ten uses 9
--max-issues --max-issues -5 uses 80
--max-transition-samples --max-transition-samples abc no cap
--tolerance --tolerance -1, --tolerance px uses 2

The cause is positiveInteger and nonNegativeNumber in packages/cli/src/commands/check.ts (around line 721). Both return the fallback for anything they can't parse. parseInt also accepts junk after a number, so --samples 5abc is read as 5.

What to do

  1. Throw CliUsageError (as parseCheckRange already does) when one of these flags is given a value that isn't a valid number in range. The error message should name the flag and the value.
  2. Leave the defaults alone when a flag isn't passed.
  3. Add tests showing that each bad value exits 2 with a usage_error under --json, and that valid values still work.

This one is medium difficulty: it touches several flags and needs a small, careful set of tests.

— Rames Jusso

Activity

  1. added
    bug
    difficulty/medium
    help wanted
    on Nov 13, 2026
  2. bardrop commented on Nov 13, 2026

    @bardrop
    Contributor

    I'd like to take this one. Plan: positiveInteger / nonNegativeNumber in check.ts take the flag name, return the default only when the flag is absent, and otherwise parse with Number() (so 5abc and 2px are rejected too) and throw CliUsageError with Invalid --<flag>: "<value>"; use a positive integer (or non-negative number). Tests in check.test.ts for each bad value from the table plus valid values/defaults, and two rows in the agent-mode flag-check table. PR coming shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty/mediumhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions