Skip to content

fix(cmd): reject NaN and Inf Savings Plan hourly commitments at validation #2213

Open

Description

@cristim

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions