fix(cmd): reject NaN and Inf Savings Plan hourly commitments at validation #2213
Copy link
Copy link
Closed
Labels
effort/xsTrivial / one-linerTrivial / one-linerimpact/fewLimited audienceLimited audiencepriority/p3Polish / idea / may never shipPolish / idea / may never shipseverity/lowMinor harmMinor harmtriagedItem has been triagedItem has been triagedtype/bugDefectDefecturgency/eventuallyNo deadlineNo deadline
Description
validateSavingsPlanPreconditions (cmd/savings_plan_purchase.go) rejects HourlyCommitment <= 0 and, after #2209, values that format to 0.00. NaN and ±Inf pass both checks: NaN <= 0 is false, and %.2f renders them as NaN / +Inf. They then reach the AWS provider, which sends fmt.Sprintf("%.2f", ...) as the commitment string.
Reachable through a CSV cell containing NaN/Inf or a bad upstream recommendation value. AWS would most likely reject the request, but the CLI should fail at its own boundary with a clear error.
Suggested fix: guard with !(x > 0) || math.IsInf(x, 0) and add table cases for NaN, +Inf and -Inf.
Found during the independent review of #2209 (out of scope there; pre-existing behaviour).
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
effort/xsTrivial / one-linerTrivial / one-linerimpact/fewLimited audienceLimited audiencepriority/p3Polish / idea / may never shipPolish / idea / may never shipseverity/lowMinor harmMinor harmtriagedItem has been triagedItem has been triagedtype/bugDefectDefecturgency/eventuallyNo deadlineNo deadline
Activity