test(aws/recs): cover SizeInMiB-nil + assert no NextPage on canceled ctx; drop em-dashes - #842
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
ChangesPointer-based recommendation parameter update
Estimated code review effort: 3 (Moderate) | ~30 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Coordination note: PR #816 (closes #218) implements the same DescribeInstanceTypes VCPU/MemoryGB population path independently. The two PRs are effectively duplicates. Whichever lands first should be merged; the other should be closed (or rebased to a tightening-only delta). Both currently open; flagging so the merger doesn't accidentally land both. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Extract ec2Tenancy, ec2Scope, and enrichEC2Compute helpers from parseEC2Details to bring its cyclomatic complexity from 14 down to 6, passing the gocyclo <=10 gate.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
Rate Limit Exceeded
|
Extract ec2Tenancy, ec2Scope, and enrichEC2Compute helpers from parseEC2Details to bring its cyclomatic complexity from 14 down to 6, passing the gocyclo <=10 gate.
|
pr-iterate: rebased on feat/multicloud-web-frontend (resolved conflict in providers/aws/recommendations/parser_services.go and parser_services_test.go - merged the base branch ResourceType guard with the PR context.Context threading). PR is otherwise progressing (mergeStateStatus will refresh). Re-invoke |
|
Verification note: this PR (closes #99) and PR #816 (closes #218) both populate ComputeDetails VCPU/MemoryGB via EC2 DescribeInstanceTypes on the same base branch. They are duplicate solutions and will conflict. Recommend merging ONE and closing the other's issue as a duplicate. The code here is correct on its own merits. Leaving the pick for a human. |
Extract ec2Tenancy, ec2Scope, and enrichEC2Compute helpers from parseEC2Details to bring its cyclomatic complexity from 14 down to 6, passing the gocyclo <=10 gate.
a6ab935 to
867b4c6
Compare
|
pr-iterate: rebased on Resolution detail (semantic, not mechanical): the base branch had independently extracted the EC2 helpers this PR added, but under the fail-loud names
Verification: Note (unchanged, for the human): this PR (#99) and PR #816 (#218) are duplicate solutions for the same ComputeDetails VCPU/MemoryGB enrichment. Merge one and close the other's issue as a duplicate. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai full review |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@providers/gcp/recommendations.go`:
- Around line 97-98: Add a nil guard at the beginning of the GetRecommendations
method in RecommendationsClientAdapter before the line that dereferences the
pointer parameter p (where params := *p occurs). Check if p is nil and return an
appropriate error instead of proceeding with the dereference to prevent a
potential nil-pointer panic at runtime.
In `@providers/gcp/services/cloudsql/client.go`:
- Around line 142-143: The GetRecommendations method in CloudSQLClient
dereferences the pointer parameter p without first checking if it is nil, which
will cause a panic if a caller passes nil. Add a nil guard check at the
beginning of the GetRecommendations method that validates p is not nil, and
return an appropriate error (such as "recommendation params cannot be nil") if
the check fails before attempting to dereference p with params := *p.
In `@providers/gcp/services/cloudstorage/client.go`:
- Around line 162-163: The GetRecommendations method in CloudStorageClient
dereferences the pointer parameter p without first checking if it is nil, which
will cause a panic if nil is passed. Add a nil guard at the beginning of the
GetRecommendations method to check if p is nil, and return an appropriate error
value before attempting to dereference it with the params := *p statement.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bdfd6c52-bd98-4c41-9b00-87c02b7dabec
📒 Files selected for processing (56)
cmd/multi_service_coverage_test.gocmd/multi_service_helpers.gocmd/multi_service_test.gocmd/multi_service_test_common_test.gointernal/purchase/mocks_test.gointernal/scheduler/scheduler.gointernal/scheduler/scheduler_test.gopkg/provider/interface.goproviders/aws/recommendations/client.goproviders/aws/recommendations/client_test.goproviders/aws/recommendations/sku.goproviders/aws/recommendations/sku_test.goproviders/aws/service_client.goproviders/aws/service_client_test.goproviders/aws/services/ec2/client.goproviders/aws/services/ec2/client_test.goproviders/aws/services/elasticache/client.goproviders/aws/services/elasticache/client_test.goproviders/aws/services/memorydb/client.goproviders/aws/services/memorydb/client_test.goproviders/aws/services/opensearch/client.goproviders/aws/services/opensearch/client_test.goproviders/aws/services/rds/client.goproviders/aws/services/rds/client_test.goproviders/aws/services/redshift/client.goproviders/aws/services/redshift/client_test.goproviders/aws/services/savingsplans/client.goproviders/aws/services/savingsplans/client_test.goproviders/azure/recommendations.goproviders/azure/recommendations_test.goproviders/azure/services/cache/client.goproviders/azure/services/cache/client_test.goproviders/azure/services/compute/client.goproviders/azure/services/compute/client_test.goproviders/azure/services/cosmosdb/client.goproviders/azure/services/cosmosdb/client_test.goproviders/azure/services/database/client.goproviders/azure/services/database/client_test.goproviders/azure/services/managedredis/client.goproviders/azure/services/managedredis/client_test.goproviders/azure/services/savingsplans/client.goproviders/azure/services/savingsplans/client_test.goproviders/azure/services/search/client.goproviders/azure/services/search/client_test.goproviders/azure/services/synapse/client.goproviders/azure/services/synapse/client_test.goproviders/gcp/recommendations.goproviders/gcp/recommendations_test.goproviders/gcp/services/cloudsql/client.goproviders/gcp/services/cloudsql/client_test.goproviders/gcp/services/cloudstorage/client.goproviders/gcp/services/cloudstorage/client_test.goproviders/gcp/services/computeengine/client.goproviders/gcp/services/computeengine/client_test.goproviders/gcp/services/memorystore/client.goproviders/gcp/services/memorystore/client_test.go
|
@coderabbitai The three GCP nil-pointer-dereference findings are false positives. Evidence:
Verification: No code change is warranted. Requesting re-review of those three threads. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Tip For best results, initiate chat on the files or code changes.
No code change is needed there; please consider those three threads withdrawn. (・x・) ✏️ Learnings added
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
providers/gcp/services/computeengine/client.go (1)
216-227: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffDuplicated
resolveRecommenderClientacross service clients.Identical logic (including doc comment) is also added in
providers/gcp/services/memorystore/client.go(lines 154-165), and likely in the cloudsql/cloudstorage clients per this cohort's file list. Consider extracting a shared helper (e.g., accepting the injected client, a constructor func, and clientOpts) into a common internal package to avoid maintaining four copies of the same resolution logic.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@providers/gcp/services/computeengine/client.go` around lines 216 - 227, The resolveRecommenderClient logic is duplicated across multiple GCP service clients, including ComputeEngineClient and the same pattern in MemorystoreClient, so extract the shared resolution flow into a common internal helper. Move the injected-client check and constructor fallback into a reusable function that accepts the existing client field, a constructor func, and clientOpts, then have each service client call that helper from its resolveRecommenderClient method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@providers/gcp/services/computeengine/client.go`:
- Around line 216-227: The resolveRecommenderClient logic is duplicated across
multiple GCP service clients, including ComputeEngineClient and the same pattern
in MemorystoreClient, so extract the shared resolution flow into a common
internal helper. Move the injected-client check and constructor fallback into a
reusable function that accepts the existing client field, a constructor func,
and clientOpts, then have each service client call that helper from its
resolveRecommenderClient method.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 34fc773f-03e9-417d-976c-497dc8db4c40
📒 Files selected for processing (56)
cmd/multi_service_coverage_test.gocmd/multi_service_helpers.gocmd/multi_service_test.gocmd/multi_service_test_common_test.gointernal/purchase/mocks_test.gointernal/scheduler/scheduler.gointernal/scheduler/scheduler_test.gopkg/provider/interface.goproviders/aws/recommendations/client.goproviders/aws/recommendations/client_test.goproviders/aws/recommendations/sku.goproviders/aws/recommendations/sku_test.goproviders/aws/service_client.goproviders/aws/service_client_test.goproviders/aws/services/ec2/client.goproviders/aws/services/ec2/client_test.goproviders/aws/services/elasticache/client.goproviders/aws/services/elasticache/client_test.goproviders/aws/services/memorydb/client.goproviders/aws/services/memorydb/client_test.goproviders/aws/services/opensearch/client.goproviders/aws/services/opensearch/client_test.goproviders/aws/services/rds/client.goproviders/aws/services/rds/client_test.goproviders/aws/services/redshift/client.goproviders/aws/services/redshift/client_test.goproviders/aws/services/savingsplans/client.goproviders/aws/services/savingsplans/client_test.goproviders/azure/recommendations.goproviders/azure/recommendations_test.goproviders/azure/services/cache/client.goproviders/azure/services/cache/client_test.goproviders/azure/services/compute/client.goproviders/azure/services/compute/client_test.goproviders/azure/services/cosmosdb/client.goproviders/azure/services/cosmosdb/client_test.goproviders/azure/services/database/client.goproviders/azure/services/database/client_test.goproviders/azure/services/managedredis/client.goproviders/azure/services/managedredis/client_test.goproviders/azure/services/savingsplans/client.goproviders/azure/services/savingsplans/client_test.goproviders/azure/services/search/client.goproviders/azure/services/search/client_test.goproviders/azure/services/synapse/client.goproviders/azure/services/synapse/client_test.goproviders/gcp/recommendations.goproviders/gcp/recommendations_test.goproviders/gcp/services/cloudsql/client.goproviders/gcp/services/cloudsql/client_test.goproviders/gcp/services/cloudstorage/client.goproviders/gcp/services/cloudstorage/client_test.goproviders/gcp/services/computeengine/client.goproviders/gcp/services/computeengine/client_test.goproviders/gcp/services/memorystore/client.goproviders/gcp/services/memorystore/client_test.go
✅ Files skipped from review due to trivial changes (4)
- providers/aws/services/opensearch/client_test.go
- providers/gcp/services/cloudstorage/client_test.go
- providers/gcp/services/computeengine/client_test.go
- providers/azure/services/cache/client_test.go
🚧 Files skipped from review as they are similar to previous changes (50)
- providers/aws/services/elasticache/client_test.go
- providers/azure/recommendations_test.go
- providers/azure/services/search/client.go
- internal/scheduler/scheduler_test.go
- providers/aws/services/savingsplans/client_test.go
- providers/azure/services/managedredis/client.go
- pkg/provider/interface.go
- providers/azure/services/compute/client_test.go
- providers/aws/services/redshift/client.go
- providers/azure/services/savingsplans/client.go
- providers/aws/services/ec2/client.go
- cmd/multi_service_test_common_test.go
- providers/aws/services/redshift/client_test.go
- providers/aws/services/rds/client_test.go
- providers/azure/services/savingsplans/client_test.go
- providers/azure/services/search/client_test.go
- internal/scheduler/scheduler.go
- providers/azure/services/synapse/client_test.go
- providers/azure/services/database/client_test.go
- providers/aws/services/memorydb/client.go
- providers/azure/services/cosmosdb/client_test.go
- providers/azure/services/database/client.go
- providers/gcp/recommendations_test.go
- providers/aws/services/savingsplans/client.go
- providers/gcp/services/memorystore/client_test.go
- cmd/multi_service_coverage_test.go
- providers/aws/services/ec2/client_test.go
- providers/aws/services/rds/client.go
- providers/aws/services/memorydb/client_test.go
- providers/azure/services/synapse/client.go
- providers/aws/recommendations/client_test.go
- providers/aws/services/opensearch/client.go
- providers/azure/recommendations.go
- providers/azure/services/compute/client.go
- providers/aws/services/elasticache/client.go
- providers/aws/service_client.go
- providers/aws/service_client_test.go
- providers/azure/services/cosmosdb/client.go
- providers/azure/services/cache/client.go
- providers/gcp/services/cloudsql/client.go
- providers/azure/services/managedredis/client_test.go
- cmd/multi_service_helpers.go
- cmd/multi_service_test.go
- providers/gcp/recommendations.go
- providers/gcp/services/cloudstorage/client.go
- providers/gcp/services/cloudsql/client_test.go
- internal/purchase/mocks_test.go
- providers/aws/recommendations/sku_test.go
- providers/aws/recommendations/sku.go
- providers/aws/recommendations/client.go
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
b981996 to
e4eb93f
Compare
Change GetRecommendations signature to *common.RecommendationParams across
all AWS/Azure/GCP providers, and replace the per-call newRateLimiter factory
on the AWS recommendations Client with a single shared *RateLimiter reset
before each call. Update all callers, mocks, and tests to match.
Fixes type mismatches introduced when origin/main moved after this branch
diverged: serviceRecsGetter interface updated to pointer params, fakeServiceClient
in azure/recommendations_test.go updated, and scheduler test matcher changed
from AnythingOfType("common.RecommendationParams") to pointer type.
Preserves the always-empty GetRecommendations for Azure Search (H1 regression
test) while keeping convertAzureSearchRecommendation for GetOfferingDetails.
Use operation-local AWS retry counters so concurrent recommendation, coverage, and utilization requests cannot corrupt each other's backoff. Honor the injected Azure Advisor function and reject nil recommendation parameters at the AWS and Azure provider boundaries.
|
Rebased onto current origin/main (force-pushed). Conflict in @coderabbitai review |
|
✅ Action performedReview finished.
|
npm audit flagged brace-expansion <1.1.16 as high severity DoS. This was disclosed 2026-07-21 and affects all PR branches equally. Lockfile-only change; no production API surface altered.
Summary
The ComputeDetails VCPU/MemoryGB implementation (issue #99) landed via the merged duplicate PR #816
(
feat(aws/recs): populate ComputeDetails.VCPU/MemoryGB via DescribeInstanceTypes, closes #218).This PR is repurposed to carry the remaining test-coverage gaps that #816 missed, plus a comment
cleanup -- nothing net-new in production code.
What is grafted on top of the already-merged #816 implementation:
TestExtractInstanceTypeSKUEntry: new sub-case "MemoryInfo present but SizeInMiB nil" -- verifiesVCPU is populated (8) while MemGB stays 0.0 when the API returns a MemoryInfo struct but omits
the SizeInMiB pointer.
TestFetchInstanceTypeCatalogue_ContextCanceled: after the pre-canceled ctx returns nil, alsoassert
pager.callCount == 0-- the stub already tracks this atomically; the assertion makesthe no-NextPage-on-canceled-ctx contract explicit and regression-tested.
Em-dash (U+2014) cleanup: replaced
--in two Warnf messages insku.goand in theinstanceTypeLookupcomment inclient.go. Em-dashes inparser_services.goare left for afollow-up (out of scope here).
What was intentionally dropped from the original #842 branch (cosmetic churn not worth the diff
noise on top of the already-clean #816 implementation):
assert.InDelta->assert.Equalswaps,requiremessage removals, struct-literal refactor ofextractInstanceTypeSKUEntry, pagerrenaming.
Closes #99
Summary by CodeRabbit
Refactor
Tests