Skip to content

fix(cmd): reject NaN and Inf for numeric sizing flags - #2165

Open
cristim wants to merge 1 commit into
mainfrom
fix/2136-target-coverage-nan
Open

cristim wants to merge 1 commit into
mainfrom
fix/2136-target-coverage-nan

Conversation

@cristim

@cristim cristim commented Oct 9, 2026

Copy link
Copy Markdown
Member

Summary

Rejects NaN and +/-Inf for --coverage, --target-coverage, --min-pool-size and --min-savings-pct in the flag validators (one requireFinite(name, v) helper), before any API call. Explicit --target-coverage 0 stays valid (documented disabled); ranges are unchanged.

Root cause: every ordered comparison with NaN is false, so --target-coverage NaN passed the <0 || >100 check, then applySizing/fetchExistingCoverage read TargetCoverage > 0 as "unset" and silently sized with --coverage (default 80). --coverage NaN reaches recfilter.ApplyCoverage (sizing.go:23), producing NaN HourlyCommitment/costs for SP recs and an arch-dependent int(NaN*count) for RI recs. --min-pool-size NaN passed the whole-number check; --min-savings-pct had no validation.

Evidence (offline)

  • TestValidateNumericFlagsRejectNonFinite drives the real flags via rootCmd.ParseFlags then the validators; it never calls runTool, so no AWS client is built. Cases: NaN, nan, +/-Inf per flag, 1e999 (rejected by the flag parser), explicit 0 and valid values.

  • Pre-fix (validators.go stashed): all 9 non-finite cases fail; post-fix pass. go vet ./..., build and go test ./cmd (463s) pass; pre-commit hooks (incl. gocyclo) pass.

Not in this PR

Closes #2136

🤖 Generated with Claude Code

Every comparison with NaN is false, so --target-coverage NaN passed the
range check and then read as "unset" in applySizing, silently sizing with
--coverage. Add requireFinite and apply it to --coverage, --target-coverage,
--min-pool-size and --min-savings-pct, before any API call.

Closes #2136

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-quarter Within the quarter impact/few Limited audience effort/xs Trivial / one-liner type/bug Defect labels Oct 9, 2026
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 52 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 5e750c3c-3c3c-49af-81c5-e3c245721374

📥 Commits

Reviewing files that changed from the base of the PR and between 22126ab and fa55e28.


📒 Files selected for processing (3)
  • CHANGELOG.md
  • cmd/validators.go
  • cmd/validators_test.go


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

Labels

effort/xs Trivial / one-liner impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cmd): validateTargetCoverage accepts NaN and applySizing silently falls back to --coverage

1 participant