fix(cli): reject invalid scale numeric options#730
Conversation
Greptile SummaryThis PR adds four parser functions (
Confidence Score: 5/5Safe to merge; the changes add parser-level validation that narrows accepted inputs without altering any happy-path logic. All changed code is additive input validation. Each parser is straightforward, correctly ordered (empty-check before coercion, safe-integer before range), and backed by focused regression tests. No data paths, state mutations, or existing behaviors are altered. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI argument string] --> B{Empty or whitespace?}
B -- yes --> ERR[InvalidArgumentError thrown]
B -- no --> C[Number coercion]
C --> D{Which parser?}
D -- parsePositiveInteger --> E{isSafeInteger AND gte 1?}
E -- no --> ERR
E -- yes --> OUT[Value returned to Commander]
D -- parseNonNegativeInteger --> F{isSafeInteger AND gte 0?}
F -- no --> ERR
F -- yes --> OUT
D -- parsePositiveNumber --> G{isFinite AND gt 0?}
G -- no --> ERR
G -- yes --> OUT
D -- parsePercentage --> H[calls parsePositiveInteger]
H --> I{parsed gt 100?}
I -- yes --> ERR
I -- no --> OUT
OUT --> J[Action handler receives clean value]
Reviews (3): Last reviewed commit: "fix(cli): validate rollout percent and e..." | Re-trigger Greptile |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
51db023 to
8583181
Compare
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
11 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
scalecount options before command actions run--max-hourly-priceCloses #729
Validation
vitest run packages/cli/src/commands/scale.test.ts(34 passed)git diff --checkbuild-actions.ts,openapi.ts, andship.ts; no errors point to the changed files