You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(providers/aws): getDurationString/getDurationValue silently fallback to 1yr on unrecognized term #1266
getDurationString (RDS, ElastiCache) and getDurationValue (EC2) silently return the 1yr duration when the term string is not "1yr", "1", "3yr", or "3":
func (c*Client) getDurationValue(termstring) int64 {
ifterm=="3yr"||term=="3" {
returnThreeYearSeconds
}
returnOneYearSeconds// silent fallback -- any unrecognized term becomes 1yr
}
This is a money-path silent fallback: a malformed term (e.g., "2yr", "invalid", or an empty string) silently issues a purchase query for a 1-year RI instead of failing loud. The convertPaymentOption functions in these same files correctly return an error on unknown values; term should follow the same pattern.
Change each function signature to return (int64/string, error) and return an explicit error for any unrecognized term (matching the convertPaymentOption pattern). Update callers (buildEC2QueryFromRec, findOfferingID preamble, getDurationString callers). Add regression tests that pass an unrecognized term and assert an error is returned before any API call.
Context
Found during adversarial review of PR #815 (findOfferingID audit). The silent fallback is pre-existing on main and out-of-scope for PR #815. Refs #515.
Verification sweep against main (101f099fb) on 2026-07-27 finds this already resolved.
RDS, ElastiCache and EC2 duration parsing now all return an explicit unsupported-term error instead of silently defaulting.
Evidence: commit bd8168a (RDS/ElastiCache) and c59c116 (EC2, PR #1481).
Recommending close. Note #1260 is the EC2 half of this same fix; consider closing both together, or #1260 as a duplicate of this one.
Verified resolved at 3c0f8ac: getDurationString (RDS, ElastiCache) and getDurationValue (EC2) now return an explicit unsupported-term error for anything outside 1yr/1/3yr/3, and every caller propagates it before the offering lookup. Evidence: providers/aws/services/ec2/client.go:672, providers/aws/services/rds/client.go:538, providers/aws/services/elasticache/client.go:447 (#1207 commit bd8168a, #1481 commit c59c116); regression tests TestFindOfferingID_InvalidTerm_ErrorsBeforeAPICall in each client_test.go. Residual axes checked: MemoryDB/OpenSearch/Redshift converters were covered by #1207; #1260 tracks the EC2 half and can close with this. Closing as completed; reopen if the behaviour recurs.
Activity
cristim commentedon Jul 27, 2026
Verification sweep against
main(101f099fb) on 2026-07-27 finds this already resolved.RDS, ElastiCache and EC2 duration parsing now all return an explicit unsupported-term error instead of silently defaulting.
Evidence: commit bd8168a (RDS/ElastiCache) and c59c116 (EC2, PR #1481).
Recommending close. Note #1260 is the EC2 half of this same fix; consider closing both together, or #1260 as a duplicate of this one.
cristim commentedon Sep 2, 2026
Verified resolved at 3c0f8ac: getDurationString (RDS, ElastiCache) and getDurationValue (EC2) now return an explicit unsupported-term error for anything outside 1yr/1/3yr/3, and every caller propagates it before the offering lookup. Evidence: providers/aws/services/ec2/client.go:672, providers/aws/services/rds/client.go:538, providers/aws/services/elasticache/client.go:447 (#1207 commit bd8168a, #1481 commit c59c116); regression tests TestFindOfferingID_InvalidTerm_ErrorsBeforeAPICall in each client_test.go. Residual axes checked: MemoryDB/OpenSearch/Redshift converters were covered by #1207; #1260 tracks the EC2 half and can close with this. Closing as completed; reopen if the behaviour recurs.