Skip to content

providers/aws/ec2: getDurationValue silently defaults unknown RI terms to 1yr #33

Closed

Description

@cristim

Found during the LeanerCloud/cloud-commitments-cli#1207 pre-merge review (pre-existing, same bug class LeanerCloud/cloud-commitments-cli#1207 fixes in 5 other clients but out of its arch-04 scope): providers/aws/services/ec2/client.go ~line 630, getDurationValue silently defaults an unrecognized term string to the 1-year duration and feeds buildEC2OfferingQuery on the EC2 RI purchase path - a silent money-path fallback (could purchase a 1yr RI when the config said something else). Fix like LeanerCloud/cloud-commitments-cli#1207: return an explicit error on every unrecognized/empty term, propagate before any API call, regression test with real bad-term inputs ('', '0', '2yr', garbage) proving fail-before/pass-after. Note: SP's normalizeTermString defaults are currently gated upstream by fail-loud convertTermToSeconds - verify and leave a guard test if so. Per feedback_no_silent_fallbacks.

Activity

  1. cristim commented on Jul 27, 2026

    @cristim
    MemberAuthor

    Verification sweep against main (101f099fb) on 2026-07-27 finds this already resolved.
    EC2's getDurationValue now returns an explicit error on an unrecognized term instead of silently defaulting to 1yr.
    Evidence: commit c59c11693 (PR LeanerCloud/cloud-commitments-cli#1481).
    Recommending close.

  2. cristim commented on Oct 16, 2026

    @cristim
    MemberAuthor

    Checked against main 740dfbd: the EC2 default is gone (providers/aws/services/ec2/client.go:731 fails loud, e6a9372). The Savings Plans normalizeTermString (providers/aws/services/savingsplans/client.go:724) still has a 1yr fallback but only runs after convertTermToSeconds (:478) has rejected unknown terms; no guard test pins that order. Marking needs-info for a close decision (or keep open only for that small test).

  3. cristim commented on Oct 20, 2026

    @cristim
    MemberAuthor

    Verified on current main. EC2 getDurationValue now fails loud on any term outside 1yr/1/3yr/3 (providers/aws/services/ec2/client.go:737 via purchasecfg.ParseTermMonths, e6a9372) and findOffering errors before any API call (client_test.go:832). The Savings Plans side is stricter than the issue asked: normalizeTermString (savingsplans/client.go:736) now errors instead of defaulting, pinned by TestNormalizeTermString (client_test.go:1749) and TestClient_GetOfferingDetails_UnknownTermErrors (:1778). Duplicate of #23. [claude-cc-libs]

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