Skip to content

fix(recommendations): wire MemoryDB NodeType from CE InstanceDetails (follow-up to #539, closes #378) - #990

Merged
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/378-memorydb-nodetype-wiring
Jun 8, 2026
Merged

cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/378-memorydb-nodetype-wiring

Conversation

@cristim

@cristim cristim commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Follow-up to merged PR #539 (closes #378 properly)

PR #539 changed parseMemoryDBDetails to read rec.ResourceType and error
loudly when it is empty, on the premise (stated in the doc comment) that the
AWS SDK has no MemoryDB sub-struct in ReservationPurchaseRecommendationDetail.

That premise is incorrect. The Cost Explorer SDK in use
(costexplorer@v1.61.0) exposes
details.InstanceDetails.MemoryDBInstanceDetails with NodeType and Region,
exactly the shape ElastiCache and Redshift already read from.

The residual bug

Nothing upstream populates rec.ResourceType before parseMemoryDBDetails
runs: parseRecommendationDetail only sets ResourceType inside each
service parser. So for MemoryDB, rec.ResourceType was always "" at entry
and every MemoryDB recommendation hit the empty-ResourceType error and was
skipped. The happy-path branch and its two unit tests (which injected
ResourceType manually) were unreachable in production.

The fix

  • Read NodeType and Region from MemoryDBInstanceDetails, mirroring the
    ElastiCache/Redshift parsers, so the happy path is reachable for real CE
    responses.
  • Keep a loud error only when the sub-struct or its NodeType is genuinely
    absent.
  • Rewrite the tests to exercise the real production path via the SDK struct
    instead of a manually injected ResourceType, adding coverage for the
    missing-sub-struct and nil-NodeType error cases plus Region parsing.

Verification

  • gofmt, go vet, go build ./...: clean.
  • go test ./providers/aws/recommendations/...: 290 passed.
  • SKIP=terraform_validate pre-commit run --files ...: all hooks pass.

(One unrelated pre-existing failure in providers/aws/services/savingsplans
test exists on the base branch and is untouched by this PR.)

Summary by CodeRabbit

  • Bug Fixes

    • Improved accuracy of AWS MemoryDB recommendation parsing by deriving offering details directly from Cost Explorer data
    • Enhanced validation and error handling for missing or invalid MemoryDB instance configurations
    • Corrected resource type and region assignment for MemoryDB recommendations
  • Tests

    • Expanded test coverage for MemoryDB parsing scenarios and error conditions

@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/s Hours type/bug Defect labels Jun 5, 2026
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b539939-02a6-4da0-af79-421783c126b5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/378-memorydb-nodetype-wiring

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

@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 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 commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 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 added 2 commits June 6, 2026 08:45
…(follow-up to #539)

PR #539 made parseMemoryDBDetails read rec.ResourceType and error loudly
when empty, with a doc comment claiming the AWS SDK has no MemoryDB sub-struct
in ReservationPurchaseRecommendationDetail. That premise is wrong: the CE SDK
(costexplorer v1.61.0) exposes details.InstanceDetails.MemoryDBInstanceDetails
with NodeType and Region, exactly like ElastiCache and Redshift.

Nothing upstream populates rec.ResourceType before parseMemoryDBDetails runs
(parseRecommendationDetail only sets it inside the service parsers themselves),
so every MemoryDB recommendation hit the empty-ResourceType error and was
skipped. The happy-path branch and its unit tests (which injected ResourceType
manually) were unreachable in production.

Read NodeType and Region from MemoryDBInstanceDetails, mirroring the
ElastiCache/Redshift parsers, so the happy path is reachable for real CE
responses. Keep a loud error only when the sub-struct or its NodeType is
genuinely absent. Rewrite the tests to exercise the real production path via
the SDK struct rather than a manually injected ResourceType.
…etails

The serviceParserFunc type requires (context.Context, *Recommendation,
*Detail) signature. The prior implementation correctly used _ context.Context;
keep that to satisfy the function type while the new body reads from details
directly.
@cristim
cristim force-pushed the fix/378-memorydb-nodetype-wiring branch from 27c1649 to e13e083 Compare June 6, 2026 06:48
@cristim

cristim commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Rebased on feat/multicloud-web-frontend. Resolved conflicts in providers/aws/recommendations/parser_services.go and providers/aws/recommendations/parser_services_test.go (HEAD had a prior intermediate version of parseMemoryDBDetails; kept the PR's version which wires NodeType from CE InstanceDetails, restored _ context.Context to satisfy serviceParserFunc signature). CR BILLING_BLOCKED; no re-trigger sent.

@cristim
cristim merged commit 5a205a6 into feat/multicloud-web-frontend Jun 8, 2026
3 of 4 checks passed
@cristim
cristim deleted the fix/378-memorydb-nodetype-wiring branch July 27, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant