Skip to content

fix(aws/recommendations): case-insensitive EC2 tenancy so AWS RI recs are not dropped - #1129

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/aws-opportunities-missing
Jun 9, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/aws-opportunities-missing

Conversation

@cristim

@cristim cristim commented Jun 9, 2026

Copy link
Copy Markdown
Member

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 the default branch and returned an error. parseRecommendations (parser_ri.go) catches that error, logs a Warning: Failed to parse recommendation detail ... and continues, silently dropping every EC2 RI recommendation.

Combined with Savings Plans collection being independently blocked by an IAM AccessDeniedException on ce: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 sha 0c10f1a)

Warning: Failed to parse recommendation detail 0: unrecognised EC2 tenancy "Shared" from Cost Explorer: must be shared (default) or dedicated; host tenancy has no corresponding RI product

(repeated on every collection cycle, for every EC2 RI detail)

This is a genuine code bug, not the corrupted-DB / offering_class situation. 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 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.

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 ./... and go vet clean.

Why the bug shipped despite green tests

The pre-existing TestParseEC2Details cases 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

… 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.
@cristim cristim added triaged Item has been triaged priority/p1 Next up; this sprint severity/high Significant harm urgency/now Drop other things impact/all-users Affects every user effort/xs Trivial / one-liner type/bug Defect labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de86055e-23f1-4fa1-9177-f9038383997a

📥 Commits

Reviewing files that changed from the base of the PR and between 0c10f1a and 848485b.

📒 Files selected for processing (2)
  • providers/aws/recommendations/parser_services.go
  • providers/aws/recommendations/parser_services_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/aws-opportunities-missing

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 4fce41f into feat/multicloud-web-frontend Jun 9, 2026
4 checks passed
@cristim
cristim deleted the fix/aws-opportunities-missing branch July 27, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/all-users Affects every user priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/now Drop other things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant