Skip to content

fix(release): resolve authoritative product type via DescribeEntity#1

Open
cristim wants to merge 2 commits into
mainfrom
fix/container-product-type-resolution
Open

fix(release): resolve authoritative product type via DescribeEntity#1
cristim wants to merge 2 commits into
mainfrom
fix/container-product-type-resolution

Conversation

@cristim

@cristim cristim commented Jun 2, 2026

Copy link
Copy Markdown
Member

Problem

release-ing a new version of a container product fails with:

could not start change set: ... ValidationException:
[Requested entity type identifier 'ServerProduct@1.0' and change type 'CreateVersion' is an invalid combination.]

Root cause

findProduct returns the first product type whose ListEntities filter matches the
product name. A single entity can surface under more than one type filter: a
ContainerProduct also appears under the ServerProduct filter. Because
ServerProduct is checked first in allProductTypes, such a product is mislabeled
ServerProduct, and StartChangeSet is then called with ServerProduct@1.0 +
CreateVersion, which AWS rejects.

The ListEntities filter type is not authoritative; DescribeEntity is.

Fix

Resolve the real product type from DescribeEntity's EntityType
(e.g. ContainerProduct@1.0, with the version suffix stripped) once an entity is
found, so the correct entity type and change type are used
(ContainerProduct@1.0 + AddDeliveryOptions for container products).

  • findProduct now consults DescribeEntity for the authoritative type, falling
    back to the matched list-filter type if the lookup yields nothing.
  • New describeEntityType helper.
  • Test mock DescribeEntity made nil-safe so existing tests that do not exercise it
    keep working.
  • Added a regression test for the dual-match case (matches ServerProduct filter
    first, but DescribeEntity reports ContainerProduct@1.0 -> resolves to
    ContainerProduct).

Testing

  • go vet ./..., go build, go test ./... all pass.
  • Verified end to end by releasing a real container-product version: the changeset
    is now created as ContainerProduct and accepted by AWS (previously rejected).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved product type resolution to reliably identify the authoritative product category when a product appears under multiple classifications; ensures downstream updates use the correct type.
    • Made the mock client more robust by returning a safe empty response when the underlying mock handler is not set.
  • Tests

    • Added test coverage for scenarios where a product matches multiple categories and authoritative information determines the correct type.

findProduct returned the first product type whose ListEntities filter
matched by name. A single entity can surface under more than one type
filter (a ContainerProduct also appears under the ServerProduct filter),
so EBS Optimizer was labelled ServerProduct and StartChangeSet was called
with ServerProduct@1.0 + CreateVersion, which AWS rejects with a
ValidationException. Resolve the real type from DescribeEntity's EntityType
so the correct entity type and change type (ContainerProduct@1.0 +
AddDeliveryOptions) are used. Mock made nil-safe and a regression test
added for the dual-match case.
@cristim cristim added the bug Something isn't working label Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c99cbd26-1778-4eb9-b2de-ed42e8b9e8db

📥 Commits

Reviewing files that changed from the base of the PR and between 843d239 and a9a3953.

📒 Files selected for processing (1)
  • product.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • product.go

📝 Walkthrough

Walkthrough

findProduct now queries DescribeEntity to determine an authoritative EntityType (stripping any @version) after ListEntities finds an entity ID; the mock DescribeEntity is nil-safe, and tests cover the dual-match scenario where DescribeEntity dictates the final type.

Changes

Product Type Resolution with DescribeEntity

Layer / File(s) Summary
Mock DescribeEntity nil-safety
mock_test.go
The mock DescribeEntity method checks if describeEntityFunc is set and returns an empty output instead of invoking a nil function.
DescribeEntity-based type resolution in findProduct
product.go
findProduct calls a new describeEntityType helper that calls DescribeEntity, strips any @<version> suffix from EntityType, and returns the resolved type (falling back to the list-filter type if missing). Minor spacing alignment edits to entityTypeVersionMap are included.
Dual-match resolution test
product_test.go
A new subtest mocks a product that appears under both ServerProduct and ContainerProduct filters and returns ContainerProduct@1.0 from DescribeEntity; the test asserts findProduct returns productTypeContainer without error.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through lists where types collide,
I asked Describe to be my guide,
A mock now guards from nil-bound blight,
Tests nod: Container wins the fight,
I nibble carrots, code runs right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 describes the main change: resolving the authoritative product type via DescribeEntity, which directly addresses the root cause of the bug mentioned in PR objectives.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/container-product-type-resolution

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
product.go (1)

293-296: ⚡ Quick win

DescribeEntity errors are silently swallowed.

When describeEntityType returns a non-nil error (e.g. throttling or a transient API failure), the de == nil guard fails and findProduct falls back to the non-authoritative list-filter type pt. This is the very condition the PR fixes, so a transient error can quietly re-surface the wrong-type ValidationException downstream in StartChangeSet. Consider at least logging the error so the fallback is observable.

This is no worse than the prior behavior, but logging makes the degraded path diagnosable.

♻️ Surface the fallback
-			if actual, de := describeEntityType(svc, *eid); de == nil && actual != "" {
-				return *eid, actual, nil
-			}
+			actual, de := describeEntityType(svc, *eid)
+			if de == nil && actual != "" {
+				return *eid, actual, nil
+			}
+			if de != nil {
+				fmt.Printf("warning: DescribeEntity failed for %s, falling back to list-filter type %s: %v\n", *eid, pt, de)
+			}
 			return *eid, pt, nil
🤖 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 `@product.go` around lines 293 - 296, When describeEntityType(svc, *eid)
returns a non-nil error inside findProduct, the error is currently ignored and
the code falls back to the non-authoritative pt; modify findProduct to log the
returned error before falling back so the degraded path is observable.
Specifically, in the block that calls describeEntityType (the lines using
variables eid, actual, de), add a processLogger (or the package's logger) call
that records the error and relevant context (eid and pt) when de != nil, then
continue to return *eid, pt, nil as before; do not change the existing return
behavior used by StartChangeSet. Ensure the logger message clearly states that
describeEntityType failed and the fallback to pt is being used.
🤖 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 `@product.go`:
- Around line 293-296: When describeEntityType(svc, *eid) returns a non-nil
error inside findProduct, the error is currently ignored and the code falls back
to the non-authoritative pt; modify findProduct to log the returned error before
falling back so the degraded path is observable. Specifically, in the block that
calls describeEntityType (the lines using variables eid, actual, de), add a
processLogger (or the package's logger) call that records the error and relevant
context (eid and pt) when de != nil, then continue to return *eid, pt, nil as
before; do not change the existing return behavior used by StartChangeSet.
Ensure the logger message clearly states that describeEntityType failed and the
fallback to pt is being used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 61d4fef2-ea6c-4a9e-a10b-a51310dacc69

📥 Commits

Reviewing files that changed from the base of the PR and between aed18f3 and 843d239.

📒 Files selected for processing (3)
  • mock_test.go
  • product.go
  • product_test.go

Surface DescribeEntity errors instead of silently falling back to the
non-authoritative list-filter type, so the degraded path is diagnosable.
Addresses CodeRabbit review on PR #1.
@cristim

cristim commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

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.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant