Skip to content

fix(cli): refuse an empty numeric flag value instead of reading it as 0 - #3793

Merged
thymikee merged 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/cli-empty-numeric-flag
Oct 18, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/cli-empty-numeric-flag

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The CLI parser converts int and number flag values with Number(value). Number('') and Number(' ') return 0, so an empty or blank value passes the finite check and becomes 0. For flags whose minimum is 0, the command runs with that value and gives no error: --retries=, --hold-ms "", --delay-ms=, --pause-ms=, --interval-ms=, --duration-ms=, --jitter-px=, and --settle-quiet=. This happens, for example, when a script passes --retries="$RETRIES" and the variable is unset. For flags with a minimum of 1 or more, the user sees Invalid <flag>: with an empty value instead of the real cause.

This change refuses an empty or blank numeric value with the existing Flag <name> requires a value. error. booleanOrString flags already refuse an empty inline value. String and enum flags do not change.

Validation

  • Base 4a8abed, head ca41e6a.
  • pnpm exec vitest run src/cli/parser/__tests__/args-validation.test.ts: base, 1 failed and 23 passed (the new test); head, 24 passed.
  • pnpm check:affected --run --head bc44accc68fa4e1006f693841fea6282cd0700ce (the same change before a rebase onto 4a8abed, which touches none of these files): format, lint, typecheck, layering, fallow, build, and vitest-related (60 files, 657 tests) passed. exactCommit=true.
  • The device lanes are GitHub-authoritative and were not run locally. The change is in CLI argument parsing only. It does not change dispatch, capture, or interaction.

View guided diff

Copilot AI balanced review requested due to automatic review settings October 17, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

This PR is ready at ca41e6a. The parser now refuses an empty numeric flag value instead of reading it as 0, and the change stays within the parser and its test. Only one check has run on this fork PR so far, so the full CI suite has not run yet. There are no conflicts. I did not run the new test or the base-versus-head failure locally. I traced them through the old code path. I also did not verify the pnpm check:affected result, which was run on the earlier head bc44acc. Not blocking, and you can take or leave these: parseSourceValue in packages/kernel/src/source-value.ts still converts strings with Number(value), so a config or remote-config profile with a numeric key set to "" or " " still becomes 0 and passes the min check (I read this in the code and did not run it, and env vars are not affected because blank values are skipped), and the blank-string guard at src/cli/parser/args.ts#L311 repeats the inline check used for booleanOrString, but the messages differ so it is fine as is. Nothing else needs to happen before merge. You could decide separately whether to apply the blank-numeric rule to config sources in a follow-up.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 17, 2026
@thymikee
thymikee merged commit 4893253 into callstack:main Oct 18, 2026
12 checks passed
@thymikee

Copy link
Copy Markdown
Member

Thanks!

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

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants