Repository navigation
Conversation
The library sends HourlyCommitment to CreateSavingsPlan formatted with "%.2f", so a positive commitment below 0.005 passed the `> 0` precondition and was submitted as "0.00". The precondition now rejects any commitment that formats as 0.00, on both the dry-run and real purchase paths. Closes LeanerCloud#2163 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 57 minutes for your next included review. View limit details
Comment |
Merge-gate review verdict: CLEAN at 69a97e4Independent adversarial review by a non-author agent (Sonnet high, cold brief, full diff Checked against the source of truth:
Non-blocking notes:
Local verification on macOS at 69a97e4 (fixture-based unit tests, no AWS calls):
Merge blockers (not code): the fork CI runs 38838595062 and 38838595305 need maintainer approval, and the PR is a draft for the author to mark ready. CodeRabbit will be run, or waived on quota, once the PR is ready. 🤖 Generated with Claude Code |
Root cause
validateSavingsPlanPreconditions(cmd/savings_plan_purchase.go) only rejectedHourlyCommitment <= 0. The library formats the commitment forCreateSavingsPlanwithfmt.Sprintf("%.2f", ...)(cloud-commitments-go/providers/aws/services/savingsplans/client.go:235at the pinned version), so a positive commitment below 0.005 (e.g.0.004) passed validation, was reported as a success by the dry run, and was sent to AWS as"0.00".Fix
Add a
spCommitmentFormat = "%.2f"constant that mirrors the library's formatting and reject any commitment that formats as"0.00", with an error that says so and names the 0.005 minimum.validatePurchasePreconditionsruns on both the main path and the--input-csvpath, dry run and real run, so both now reject such rows before any API call.Closes #2163
Verification
All evidence is unit-level (no AWS calls). Run with
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/nullbecause this machine's default AWS profile is invalid, which otherwise breaks some unrelated tests.New test
TestValidatePurchasePreconditions_RejectsCommitmentThatRoundsToZero:0.001,0.004,0.00499must be rejected (error mentions0.00);0.005,0.01,1.5must still be accepted.go build -o cudly ./cmd: OKgo test -short -race -count=1 ./...:ok github.com/LeanerCloud/cloud-commitments-cli/cmdgo vet ./...: cleangolangci-lint run(v2.10.1): 0 issuesgocyclo -over 10 cmd/savings_plan_purchase.go: silentbash scripts/gosec-hook.sh cmd/savings_plan_purchase.go: 0 issues;gofmt -l cmd: clean;make tidy-check: cleanMutation note: if the check is removed, or the format constant drifts to a finer precision (e.g.
%.3f), the new test fails on0.001.Real-cloud gap: not exercised against a real
CreateSavingsPlancall. The rejection depends only on the pinned library's%.2fformatting, which was checked in the module source. If the library's formatting changes,spCommitmentFormatmust change with it.Out of scope
<= 0and the new check, because it formats as"NaN". CSV parsing already validates numeric bounds (fix(cli): validate CSV headers, encoding and numeric bounds #2145), so this was left alone here.Maintainer: please mirror the issue's triage labels onto this PR:
triaged,priority/p3,severity/low,urgency/eventually,impact/few,effort/xs,type/bug.🤖 Generated with Claude Code