Skip to content

fix(aws/elasticache): guard the offering lookup against a missing or wrong engine - #612

Open
cristim wants to merge 2 commits into
mainfrom
fix/aws-elasticache-offering-guard
Open

cristim wants to merge 2 commits into
mainfrom
fix/aws-elasticache-offering-guard

Conversation

@cristim

@cristim cristim commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Part of #53

What

ElastiCache.findOfferingID sent the Cost Explorer ProductDescription verbatim as the engine filter, including an empty value, and scanElastiCacheOfferingPage checked only the payment option of the first offering (finding A07-033 and the "ElastiCache offering lookup" item). Now:

  • an empty or blank engine is refused before any API call, with an error naming the missing field;
  • the engine is lowercased for the request (ElastiCache reports lowercase engines);
  • the first offering must also match node type, duration and engine (case-insensitive), else the existing "API filter mismatch" hard error.

Why this item: it is the one purchase path where a wrong-product reservation (other engine, node type or term) could be bought on a mismatch or empty filter. Offering price vs approved cost is in #611.

The existing happy-path fixture and one pricing case now carry Duration/ProductDescription or expect the filter-mismatch error (a 3yr offering for a 1yr request is rejected by the scan before pricing).

Not covered (left on #53)

Remaining items other than the SP offering-ID, SP rounding and CE strict validation already merged, and the EC2 price check in #611.

Proof

  • New tests fail on origin/main code (empty engine, wrong node/duration/engine); each of removing the empty-engine guard, the duration check and the lowercasing makes one fail.
  • providers/aws: build, vet, go test -timeout 300s -count=1 ./..., golangci-lint v2.10.1 with the repo config, gocyclo: clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • ElastiCache purchases now require a valid engine selection; blank or whitespace-only values are rejected.
    • Offering selection now verifies the requested node type, duration, payment option, and engine before completing a purchase.
    • Engine values are normalized for consistent matching and reporting.
    • Improved error messages identify when no offering matches the selected purchase details.

…wrong engine

findOfferingID sent the Cost Explorer ProductDescription verbatim as the
engine filter, including an empty value, and the page scan checked only the
payment option of the first offering, so an offering for a different engine,
node type or term could be bought.

Refuse an empty engine with an error naming the missing field, send the
engine lowercased as ElastiCache reports it, and fail on a first offering
whose node type, duration or engine differs from the request. Other #53
items are not covered here.

Part of #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 6f4afafa-d7b5-4529-811b-87219bc21d32
📥 Commits

Reviewing files that changed from the base of the PR and between 03f40a3 and 00537d5.

📒 Files selected for processing: 5
  • CHANGELOG.md
  • providers/aws/services/elasticache/client.go
  • providers/aws/services/elasticache/client_test.go
  • providers/aws/services/elasticache/offering_guard_test.go
  • providers/aws/services/elasticache/offering_price_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

ElastiCache offering lookup now rejects recommendations without an engine and normalizes the engine before querying. It selects an offering only when its payment option, node type, duration, and engine match the request.

Changes: ElastiCache offering validation

Layer / File(s) Summary
Normalize offering lookup inputs
providers/aws/services/elasticache/client.go
Lookup rejects missing engines, normalizes engine values, and parses the requested duration into seconds.
Validate offerings before selection
providers/aws/services/elasticache/client.go, providers/aws/services/elasticache/*_test.go, CHANGELOG.md
Offering scanning checks payment option, node type, duration, and engine before returning an ID. Tests cover missing engines, normalized filters, mismatches, and successful selection. The changelog records the validation change.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 00537

No actionable merge-blocking issue is established; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: preventing ElastiCache offering lookups when the engine is missing or incorrect.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant