Skip to content

Numeric flags accept anything and fail silently as NaN #5

Description

@royalpinto007

--max, --max-tool and --price all go straight through Number(...) with no check:

const price = Number(flag("--price", 3));
maxTokens: flag("--max", null) ? Number(flag("--max", null)) : null,

tokencut payload.json --compact --max abc gives maxTokens: NaN. The trim loop condition is total > NaN, which is always false, so the command reports "saved 0 tokens" and exits 0. It looks like the payload was already under budget.

--price abc is worse: every cost in the output becomes $NaN.

Acceptance

  • A non-numeric or negative value for any of the three flags exits non-zero with a message naming the flag and what it got
  • --max 0 is still accepted (a legitimate, if extreme, budget)
  • Tests cover a bad value for each flag

Good first issue: one small helper and three call sites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions