Repository navigation
fix(cli): bound --min-savings-pct to 0-100 - #2231
Merged
Merged
Conversation
--min-savings-pct was only checked for being finite. A negative value behaved as no filter and a value above 100 dropped every recommendation, since savings percentages are measured against on-demand and cannot exceed 100. Reject both at validation, document the range, and rename the flag-parsing validation test to cover out-of-range as well as non-finite values. Closes #2161 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reached
This review includes 4 billable files and costs up to $1.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 27 minutes for your next included review. View limit details
Comment |
Member
Author
Independent review verdict: CLEAN at 2ca29ccReviewer: fresh Claude agent (Sonnet, high effort), not the author. Coordinator: claude-cc-reviewer. What was checked:
Gate:
|
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.
Closes #2161
Summary
--min-savings-pctwas only checked for being finite. That allowed two silent mistakes:MinSavingsPct > 0.SavingsPercentageis AWS'sEstimatedMonthlySavingsPercentageagainst on-demand (the comparison is atpkg/scorer/scorer.go:88), so it can never exceed 100.This PR adds the following:
validateCoverageAndSavingsPctnow rejects values outside [0, 100] withmin-savings-pct must be between 0 and 100, got: <v>. Both ends are inclusive, so0keeps today's "no filter" default.docs/cli/filtering.mddocuments the range, andCHANGELOG.mdhas an entry under Fixed.TestValidateNumericFlagsRejectInvalid, since it now covers out-of-range values as well as non-finite ones.Validation ordering: the range check runs before the CSV-mode refusal, so
--min-savings-pct 150 --input-csv xreports the range error. Both reject the run.Evidence (local, macOS,
GOTOOLCHAIN=go1.26.9; unit tests through the real flag set)validators.gochange stashed, the newmin-savings-pct negativeandmin-savings-pct above 100cases fail. With the change, they pass, and100stays valid.make buildpasses.go vet ./...passes.go test -race ./cmd/...: 1472 passed.scripts/test-git-secrets-allowlist.sh: 44/44.PreRunE. Its one low finding, about where the tests sit and what the table is named, is applied.🤖 Generated with Claude Code