Repository navigation
fix(aws/recommendations): case-insensitive EC2 tenancy so AWS RI recs are not dropped - #1129
Conversation
… are not dropped
Cost Explorer returns the EC2 RI tenancy title-cased ("Shared",
"Dedicated", "Host"), but resolveEC2Tenancy compared it case-sensitively
against lowercase "shared"/"dedicated". Every real recommendation hit the
default branch and errored; parseRecommendations logged a warning and
continue'd, silently dropping all EC2 RI recommendations. With Savings
Plans collection separately blocked by an IAM AccessDenied, AWS produced
zero recommendations and the dashboard showed no AWS opportunities.
Normalise the input with strings.ToLower(strings.TrimSpace(...)) before
matching, mirroring the existing whitespace-tolerant handling on the RDS
DeploymentOption path. The fail-loud M5 behaviour is preserved: "host"
(Dedicated Hosts, no RI product) and any unknown value still error rather
than collapse to a default-tenancy buy.
Regression test: replicates the production casing ("Shared"/"Dedicated"
plus surrounding whitespace) which fails on the pre-fix parser, and
asserts title-cased "Host" still errors.
|
Warning Review limit reached
More reviews will be available in 7 minutes. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Problem
On the live GUI, AWS opportunities/recommendations are missing entirely. AWS is the primary, most-tested provider, so this is a serious functional regression.
Root cause
resolveEC2Tenancy(providers/aws/recommendations/parser_services.go) mapped the Cost Explorer EC2 RI tenancy case-sensitively against lowercase"shared"/"dedicated". Cost Explorer actually returns the value title-cased ("Shared","Dedicated","Host"), so every real recommendation fell through to thedefaultbranch and returned an error.parseRecommendations(parser_ri.go) catches that error, logs aWarning: Failed to parse recommendation detail ...andcontinues, silently dropping every EC2 RI recommendation.Combined with Savings Plans collection being independently blocked by an IAM
AccessDeniedExceptiononce:GetSavingsPlansPurchaseRecommendation(a separate permissions issue, not in scope here), AWS produced zero recommendations and the dashboard showed no AWS opportunities.Live log evidence (
/aws/lambda/cudly-dev-426fc8af-api, deployed sha0c10f1a)(repeated on every collection cycle, for every EC2 RI detail)
This is a genuine code bug, not the corrupted-DB /
offering_classsituation. The read path (SELECT payload FROM recommendations+ provider/account WHERE) never references a migration-gap column; the data was missing because nothing was ever stored for AWS.Fix
Normalise the tenancy with
strings.ToLower(strings.TrimSpace(...))before matching, mirroring the existing whitespace-tolerant handling already used on the RDSDeploymentOptionpath. The fail-loud M5 behaviour is preserved:"host"(Dedicated Hosts, no RI product) and any unknown value still error rather than collapse to a default-tenancy buy.Test
Added a regression test that replicates the exact production casing (
"Shared"/"Dedicated"plus surrounding whitespace). Verified it fails on the pre-fix parser (3 new positive cases) and passes after the fix; also asserts title-cased"Host"still errors. Full package suite: 331 passed;go build ./...andgo vetclean.Why the bug shipped despite green tests
The pre-existing
TestParseEC2Detailscases only used lowercase"shared"/"dedicated", never the real Cost Explorer casing. The tests exercised a casing the live data does not use, so they stayed green while the feature was broken in production.🤖 Generated with claude-flow