fix(cli): reject malformed numeric options - #3596
Open
GautamSharma99 wants to merge 1 commit into
Open
Conversation
GautamSharma99
requested review from
4shub,
carenthomas,
christinatong01,
cpacker,
jnjpng,
kl2806 and
sarahwooders
as code owners
July 31, 2026 10:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the CLI numeric-option parsing paths described in #3586.
The agents, environments, and messages subcommands previously used three copies of a
parseInt()-based helper. That accepted numeric prefixes such as10junk, allowed zero and negative pagination values, and silently replaced fully nonnumeric user input with a default. The dream timeout performed a separate partial validation and therefore accepted values such as30seconds.This PR routes those options through the existing shared CLI integer-flag owner and makes its parsing strict:
Bounds
--limit): 1 through 1,000;--max-pages): 1 through 1,000;--timeout): 1 through 86,400 seconds.The CLI help now documents these ranges next to each option.
Implementation details
parsePositiveIntFlag()instead of introducing another numeric parser. Existing callers retainundefinedfor an omitted flag, while malformed prefixes, fractions, unsafe integers, and out-of-range values now throw a consistent validation error.parseLimit()implementations from agents, environments, and messages.Tests
Added table-driven coverage for:
NaNinput;Number.MAX_SAFE_INTEGER;Validation performed:
bun test src/cli/flag-utils.test.ts src/cli/subcommands/agents.test.ts src/cli/subcommands/environments.test.ts src/cli/subcommands/messages.test.ts src/cli/subcommands/dream.test.ts(52 passed)bun run check(all 12 checks passed)Closes #3586