Skip to content

fix: validate features before publishing plans/add-ons - #3661

Merged
chrisgacsal merged 1 commit into
mainfrom
fix/plan-addon-feature
Dec 4, 2025
Merged

chrisgacsal merged 1 commit into
mainfrom
fix/plan-addon-feature

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Dec 3, 2025 •

Copy link
Copy Markdown
Collaborator

Overview

Validate ratecard features before publishing plans/add-ons.

Summary by CodeRabbit

  • New Features

    • Validation now verifies that features referenced by rate cards, plans, and add-ons exist, match, and are not archived; returns distinct issues for not found, archived, and id/key mismatch.
    • Error messages include contextual field information to make fixes easier.
  • Bug Fixes

    • Aggregated validation reporting: multiple validation errors across rate cards, plans, and add-ons are collected and returned together during publish operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@chrisgacsal chrisgacsal self-assigned this Dec 3, 2025
@chrisgacsal chrisgacsal added the release-note/bug-fix Release note: Bug Fixes label Dec 3, 2025
@chrisgacsal
chrisgacsal requested a review from a team as a code owner December 3, 2025 20:36
@coderabbitai

coderabbitai Bot commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a namespaced feature resolver and feature-aware validators for rate cards, plans, and add‑ons. Services publishing plans/add‑ons now resolve referenced features (by id/key) and aggregate validation issues including new errors for feature not found, archived, or id/key mismatch.

Changes

Cohort / File(s) Summary
Feature resolver & errors
openmeter/productcatalog/featureresolver.go, openmeter/productcatalog/errors.go
Adds NamespacedFeatureResolver and constructor NewNamespacedFeatureResolver; implements resolution by id/key within a namespace and returns not-found/conflict errors. Introduces three validation issues: rate_card_feature_not_found, rate_card_feature_archived, rate_card_feature_mismatch.
Rate card validation
openmeter/productcatalog/ratecard.go
Adds ValidateRateCardsWithFeatures(ctx, resolver) to resolve each rate card's feature, detect not-found/mismatch/archived conditions, and aggregate validation errors.
Plan validation & service integration
openmeter/productcatalog/plan.go, openmeter/productcatalog/plan/service/plan.go
Adds ValidatePlanWithFeatures(ctx, resolver) (applies rate-card validation per phase) and integrates feature-based validation into PublishPlan, collecting and joining validation errors.
Add‑on validation & service integration
openmeter/productcatalog/addon.go, openmeter/productcatalog/addon/service/addon.go
Adds ValidateAddonWithFeatures(ctx, resolver) delegating to rate-card validation; PublishAddon now collects validation errors (using an error slice and errors.Join) and returns a combined GenericValidationError when present.

Sequence Diagram(s)

sequenceDiagram
    participant Service as PublishPlan/PublishAddon
    participant Validator as ValidatePlan/AddonWithFeatures
    participant RCValidator as ValidateRateCardsWithFeatures
    participant Resolver as NamespacedFeatureResolver
    participant FeatureSvc as FeatureConnector (ListFeatures)

    Service->>Validator: Validate with NamespacedFeatureResolver(namespace)
    Validator->>RCValidator: Validate rate cards (per phase/plan/add-on)
    RCValidator->>Resolver: Resolve feature by id/key
    Resolver->>FeatureSvc: ListFeatures(namespace, ids/keys, page=1,size=100)
    FeatureSvc-->>Resolver: feature(s) or none
    alt single matching feature
      Resolver-->>RCValidator: feature object
      RCValidator-->>Validator: ok or archived/mismatch error
    else no feature
      Resolver-->>RCValidator: not-found error
      RCValidator-->>Validator: error
    end
    Validator-->>Service: aggregated errors (joined) or success
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review areas:
    • featureresolver.go — correctness of resolution logic, pagination choice, and conflict detection.
    • ratecard.go validator — mapping to new errors, archived detection, and error aggregation.
    • Service changes in plan/service/plan.go and addon/service/addon.go — error collection, wrapping, and preservation of existing side effects.
    • errors.go — conformity of new validation issues (fields, severity, HTTP status).

Possibly related PRs

Suggested labels

area/product-catalog

Suggested reviewers

  • GAlexIHU
  • turip
  • tothandras

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change—adding feature validation for plans and add-ons before publishing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/plan-addon-feature

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d016ae9 and b1d9fa7.

📒 Files selected for processing (7)
  • openmeter/productcatalog/addon.go (2 hunks)
  • openmeter/productcatalog/addon/service/addon.go (2 hunks)
  • openmeter/productcatalog/errors.go (1 hunks)
  • openmeter/productcatalog/featureresolver.go (1 hunks)
  • openmeter/productcatalog/plan.go (2 hunks)
  • openmeter/productcatalog/plan/service/plan.go (1 hunks)
  • openmeter/productcatalog/ratecard.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • openmeter/productcatalog/featureresolver.go
  • openmeter/productcatalog/plan/service/plan.go
  • openmeter/productcatalog/plan.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit configuration file

**/*.go: In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them.

Performance should be a priority in critical code paths. Anything related to event ingestion, message processing, database operations (regardless of database) should be vetted for potential performance bottlenecks.

Files:

  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/addon/service/addon.go
  • openmeter/productcatalog/errors.go
  • openmeter/productcatalog/addon.go
🧠 Learnings (1)
📚 Learning: 2025-04-21T08:32:31.689Z
Learnt from: chrisgacsal
Repo: openmeterio/openmeter PR: 2699
File: openmeter/productcatalog/planaddon/service/service_test.go:210-211
Timestamp: 2025-04-21T08:32:31.689Z
Learning: In `productcatalog.UsageBasedRateCard`, the `BillingCadence` field is a non-pointer `isodate.Period`, while in `productcatalog.FlatFeeRateCard`, `BillingCadence` is a pointer type (`*isodate.Period`). This means `MonthPeriod` should be used directly for `UsageBasedRateCard` (not `&MonthPeriod`).

Applied to files:

  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/errors.go
🧬 Code graph analysis (4)
openmeter/productcatalog/ratecard.go (5)
pkg/models/fielddescriptor.go (2)
  • NewFieldSelectorGroup (220-236)
  • NewFieldSelector (213-218)
pkg/models/fieldexpression.go (1)
  • NewFieldAttrValue (58-60)
pkg/models/errors.go (2)
  • IsGenericNotFoundError (57-65)
  • IsGenericConflictError (87-95)
openmeter/productcatalog/errors.go (3)
  • ErrRateCardFeatureNotFound (106-112)
  • ErrRateCardFeatureMismatch (126-132)
  • ErrRateCardFeatureArchived (116-122)
pkg/clock/clock.go (1)
  • Now (14-21)
openmeter/productcatalog/addon/service/addon.go (4)
openmeter/productcatalog/featureresolver.go (1)
  • NewNamespacedFeatureResolver (18-25)
app/common/namespace.go (1)
  • Namespace (13-15)
openmeter/productcatalog/addon.go (1)
  • ValidateAddonWithFeatures (322-326)
pkg/models/errors.go (1)
  • NewGenericValidationError (138-140)
openmeter/productcatalog/errors.go (3)
pkg/models/errors.go (1)
  • ErrorCode (294-294)
pkg/models/validationissue.go (3)
  • NewValidationIssue (273-283)
  • WithFieldString (224-232)
  • WithCriticalSeverity (240-242)
pkg/framework/commonhttp/errors.go (1)
  • WithHTTPStatusCodeAttribute (82-84)
openmeter/productcatalog/addon.go (6)
openmeter/productcatalog/featureresolver.go (1)
  • NamespacedFeatureResolver (13-16)
pkg/models/validator.go (1)
  • ValidatorFunc (10-10)
openmeter/productcatalog/addon/addon.go (1)
  • Addon (15-27)
app/common/productcatalog.go (1)
  • Addon (41-43)
openmeter/productcatalog/ratecard.go (2)
  • ValidateRateCardsWithFeatures (847-886)
  • RateCards (519-519)
openmeter/productcatalog/addon/ratecard.go (1)
  • RateCards (152-152)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Migration Checks
  • GitHub Check: Test
  • GitHub Check: Lint
  • GitHub Check: Code Generators
  • GitHub Check: Build
  • GitHub Check: Repository Scan
  • GitHub Check: Analyze (go)
🔇 Additional comments (7)
openmeter/productcatalog/addon.go (2)

4-4: LGTM! Context import added for feature validation.

The context import is needed for the new ValidateAddonWithFeatures function signature.


322-326: Nice clean delegation to rate card validation!

The function correctly delegates addon feature validation to the underlying rate card validation logic. This keeps the abstraction layers clean and maintainable.

openmeter/productcatalog/ratecard.go (2)

4-12: LGTM! Required imports added.

Context and clock imports are properly added for the new feature validation logic.


847-886: Solid feature validation logic with good error handling!

The function properly:

  • Skips rate cards without feature references
  • Resolves features using the namespaced resolver
  • Maps resolver errors to appropriate validation errors
  • Checks for archived features using a time comparison
  • Aggregates all validation errors for a complete picture

The error aggregation pattern is clean and the field selectors will help users pinpoint issues.

openmeter/productcatalog/addon/service/addon.go (2)

5-5: LGTM! Errors import added for error aggregation.

The errors package is needed for the errors.Join call in the updated validation logic.


514-537: Great error aggregation pattern! Plus, the copy-paste issue is fixed.

The updated validation flow properly:

  • Collects errors from both Publishable() and feature validation
  • Uses a NamespacedFeatureResolver scoped to the addon's namespace
  • Joins all validation errors into a single GenericValidationError
  • Provides clear context with id, key, and version in error messages

Also noticed the error message correctly says "invalid add-on" now (line 530), so the previous review comment about the copy-paste bug has been addressed. Nice work!

openmeter/productcatalog/errors.go (1)

104-132: New feature validation errors look good!

The three new error definitions (FeatureNotFound, FeatureArchived, FeatureMismatch) follow the established pattern in this file:

  • Clear, descriptive error codes
  • Concise messages
  • Appropriate field references ("featureKey")
  • Critical severity (makes sense for feature validation)
  • HTTP 400 status codes

These integrate nicely with the new rate card feature validation logic.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
openmeter/productcatalog/ratecard.go (1)

847-848: Consider using the type alias for consistency.

The return type func(cards RateCards) error is functionally equivalent to models.ValidatorFunc[RateCards], but using the type alias would be more consistent with other validators in this file (like ValidateRateCards() at line 605).

-func ValidateRateCardsWithFeatures(ctx context.Context, resolver NamespacedFeatureResolver) func(cards RateCards) error {
+func ValidateRateCardsWithFeatures(ctx context.Context, resolver NamespacedFeatureResolver) models.ValidatorFunc[RateCards] {
openmeter/productcatalog/addon/service/addon.go (1)

526-527: Comment also mentions "plan" instead of "add-on".

While you're at it, the comment on line 526 says "Validate plan with features" but should say "Validate add-on with features".

-		// Validate plan with features
+		// Validate add-on with features
 		resolver := productcatalog.NewNamespacedFeatureResolver(s.feature, params.Namespace)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a3e63f and e48141e.

📒 Files selected for processing (7)
  • openmeter/productcatalog/addon.go (2 hunks)
  • openmeter/productcatalog/addon/service/addon.go (2 hunks)
  • openmeter/productcatalog/errors.go (1 hunks)
  • openmeter/productcatalog/featureresolver.go (1 hunks)
  • openmeter/productcatalog/plan.go (2 hunks)
  • openmeter/productcatalog/plan/service/plan.go (1 hunks)
  • openmeter/productcatalog/ratecard.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit configuration file

**/*.go: In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them.

Performance should be a priority in critical code paths. Anything related to event ingestion, message processing, database operations (regardless of database) should be vetted for potential performance bottlenecks.

Files:

  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/plan/service/plan.go
  • openmeter/productcatalog/plan.go
  • openmeter/productcatalog/addon/service/addon.go
  • openmeter/productcatalog/featureresolver.go
  • openmeter/productcatalog/addon.go
  • openmeter/productcatalog/errors.go
🧠 Learnings (1)
📚 Learning: 2025-04-21T08:32:31.689Z
Learnt from: chrisgacsal
Repo: openmeterio/openmeter PR: 2699
File: openmeter/productcatalog/planaddon/service/service_test.go:210-211
Timestamp: 2025-04-21T08:32:31.689Z
Learning: In `productcatalog.UsageBasedRateCard`, the `BillingCadence` field is a non-pointer `isodate.Period`, while in `productcatalog.FlatFeeRateCard`, `BillingCadence` is a pointer type (`*isodate.Period`). This means `MonthPeriod` should be used directly for `UsageBasedRateCard` (not `&MonthPeriod`).

Applied to files:

  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/errors.go
🧬 Code graph analysis (6)
openmeter/productcatalog/plan/service/plan.go (3)
openmeter/productcatalog/featureresolver.go (1)
  • NewNamespacedFeatureResolver (18-25)
app/common/namespace.go (1)
  • Namespace (13-15)
openmeter/productcatalog/plan.go (1)
  • ValidatePlanWithFeatures (333-352)
openmeter/productcatalog/plan.go (6)
openmeter/productcatalog/featureresolver.go (1)
  • NamespacedFeatureResolver (13-16)
pkg/models/validator.go (1)
  • ValidatorFunc (10-10)
openmeter/productcatalog/plan/plan.go (1)
  • Plan (18-30)
pkg/models/fielddescriptor.go (2)
  • NewFieldSelectorGroup (220-236)
  • NewFieldSelector (213-218)
openmeter/productcatalog/ratecard.go (2)
  • ValidateRateCardsWithFeatures (847-882)
  • RateCards (519-519)
pkg/models/errors.go (1)
  • ErrorWithFieldPrefix (340-346)
openmeter/productcatalog/addon/service/addon.go (4)
openmeter/productcatalog/featureresolver.go (1)
  • NewNamespacedFeatureResolver (18-25)
app/common/namespace.go (1)
  • Namespace (13-15)
openmeter/productcatalog/addon.go (1)
  • ValidateAddonWithFeatures (322-326)
pkg/models/errors.go (1)
  • NewGenericValidationError (138-140)
openmeter/productcatalog/featureresolver.go (4)
openmeter/productcatalog/feature/connector.go (1)
  • FeatureConnector (29-36)
app/common/namespace.go (1)
  • Namespace (13-15)
pkg/pagination/page.go (1)
  • Page (14-17)
pkg/models/errors.go (2)
  • NewGenericNotFoundError (38-40)
  • NewGenericConflictError (68-70)
openmeter/productcatalog/addon.go (4)
openmeter/productcatalog/featureresolver.go (1)
  • NamespacedFeatureResolver (13-16)
pkg/models/validator.go (1)
  • ValidatorFunc (10-10)
openmeter/productcatalog/addon/addon.go (1)
  • Addon (15-27)
openmeter/productcatalog/ratecard.go (2)
  • ValidateRateCardsWithFeatures (847-882)
  • RateCards (519-519)
openmeter/productcatalog/errors.go (3)
pkg/models/errors.go (1)
  • ErrorCode (294-294)
pkg/models/validationissue.go (3)
  • NewValidationIssue (273-283)
  • WithFieldString (224-232)
  • WithCriticalSeverity (240-242)
pkg/framework/commonhttp/errors.go (1)
  • WithHTTPStatusCodeAttribute (82-84)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Lint
  • GitHub Check: Migration Checks
  • GitHub Check: Test
  • GitHub Check: Code Generators
  • GitHub Check: Build
  • GitHub Check: Repository Scan
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
openmeter/productcatalog/addon.go (1)

321-326: LGTM!

Clean and straightforward delegation to ValidateRateCardsWithFeatures. The pattern is consistent with the plan validation approach, keeping things nicely DRY.

openmeter/productcatalog/plan/service/plan.go (1)

512-519: LGTM!

The feature validation integrates nicely into the existing error aggregation flow. Error messages include enough context (id, key, version) for debugging, which is great.

openmeter/productcatalog/plan.go (1)

332-352: LGTM!

Nice implementation! The phase field selector wrapping gives good context for debugging when validation fails. The iteration pattern and error aggregation are consistent with the existing codebase style.

openmeter/productcatalog/ratecard.go (1)

861-877: The nil pointer dereference concern is not valid.

The NamespacedFeatureResolver.Resolve implementation (featureresolver.go:56-58) explicitly returns an error when both id and key are nil or empty. This error is caught by the existing error handling logic and the loop continues before feat.ArchivedAt is accessed, preventing any nil dereference. No code changes are necessary.

Likely an incorrect or invalid review comment.

openmeter/productcatalog/featureresolver.go (3)

13-16: Clean interface design!

The interface is well-defined with a clear separation of concerns. The WithNamespace method allows for flexible namespace switching while maintaining immutability of the resolver.


41-44: Good defensive nil check on the service.

Nice catch upfront - returning an early, clear error if the connector wasn't wired properly is solid.


64-67: Hardcoded pagination may be limiting, but likely fine for this use case.

PageSize of 100 for a lookup by specific ID/key should be more than sufficient. Just a heads-up in case the use case ever expands.

openmeter/productcatalog/errors.go (2)

104-132: New error definitions look good and follow existing patterns.

The three new error codes are well-structured:

  • Appropriate CriticalSeverity for validation issues blocking publish
  • Consistent use of featureKey field
  • HTTP 400 status for client-side validation errors
  • Clear, descriptive messages

These align nicely with the existing error conventions in this file.


114-122: No action needed—ErrRateCardFeatureArchived is properly used.

The error is correctly applied in ratecard.go at line 876 with dedicated validation logic that explicitly checks the ArchivedAt field: if feat.ArchivedAt != nil && clock.Now().UTC().After(feat.ArchivedAt.UTC()). This validation is separate from the NamespacedFeatureResolver.Resolve behavior and appropriately uses the error when an archived feature is detected.

@chrisgacsal
chrisgacsal force-pushed the fix/plan-addon-feature branch from e48141e to d016ae9 Compare December 3, 2025 21:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
openmeter/productcatalog/addon.go (1)

321-326: Wire addon feature validation into rate‑card validator (plus doc‑comment nit)

The ValidateAddonWithFeatures helper looks solid: closing over ctx and the NamespacedFeatureResolver and delegating to ValidateRateCardsWithFeatures keeps behavior aligned with the rate‑card implementation and the new error codes.

One small polish you might consider: add a GoDoc comment so this exported helper shows up clearly in docs alongside ValidateAddonMeta, ValidateAddonRateCards, etc.

Example:

- func ValidateAddonWithFeatures(ctx context.Context, resolver NamespacedFeatureResolver) models.ValidatorFunc[Addon] {
+// ValidateAddonWithFeatures returns a validator that checks addon rate cards
+// against features resolved via the provided NamespacedFeatureResolver.
+func ValidateAddonWithFeatures(ctx context.Context, resolver NamespacedFeatureResolver) models.ValidatorFunc[Addon] {
openmeter/productcatalog/featureresolver.go (1)

41-89: Resolve logic and archived handling look correct; consider slightly richer errors

The overall flow here looks good to me:

  • Guarding against a nil FeatureConnector and missing id/key.
  • Building IDsOrKeys from non‑empty pointers.
  • Calling ListFeatures with IncludeArchived: true so downstream can distinguish “not found” vs “archived”.
  • Mapping zero results to GenericNotFound and multi‑ID results to GenericConflict, which lines up with how ValidateRateCardsWithFeatures reacts.

If you ever want easier debugging in logs, you could optionally include the requested id/key in the not‑found / conflict messages, e.g.:

-	if len(features.Items) == 0 {
-		return nil, models.NewGenericNotFoundError(errors.New("feature"))
-	}
+	if len(features.Items) == 0 {
+		return nil, models.NewGenericNotFoundError(
+			fmt.Errorf("feature not found for id=%q key=%q", lo.FromPtr(id), lo.FromPtr(key)),
+		)
+	}

Same idea could apply to the conflict error. Not required for correctness, just a small quality‑of‑life tweak if you find yourself debugging these often.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e48141e and d016ae9.

📒 Files selected for processing (7)
  • openmeter/productcatalog/addon.go (2 hunks)
  • openmeter/productcatalog/addon/service/addon.go (2 hunks)
  • openmeter/productcatalog/errors.go (1 hunks)
  • openmeter/productcatalog/featureresolver.go (1 hunks)
  • openmeter/productcatalog/plan.go (2 hunks)
  • openmeter/productcatalog/plan/service/plan.go (1 hunks)
  • openmeter/productcatalog/ratecard.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • openmeter/productcatalog/plan.go
  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/plan/service/plan.go
  • openmeter/productcatalog/addon/service/addon.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit configuration file

**/*.go: In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them.

Performance should be a priority in critical code paths. Anything related to event ingestion, message processing, database operations (regardless of database) should be vetted for potential performance bottlenecks.

Files:

  • openmeter/productcatalog/addon.go
  • openmeter/productcatalog/featureresolver.go
  • openmeter/productcatalog/errors.go
🧠 Learnings (1)
📚 Learning: 2025-04-21T08:32:31.689Z
Learnt from: chrisgacsal
Repo: openmeterio/openmeter PR: 2699
File: openmeter/productcatalog/planaddon/service/service_test.go:210-211
Timestamp: 2025-04-21T08:32:31.689Z
Learning: In `productcatalog.UsageBasedRateCard`, the `BillingCadence` field is a non-pointer `isodate.Period`, while in `productcatalog.FlatFeeRateCard`, `BillingCadence` is a pointer type (`*isodate.Period`). This means `MonthPeriod` should be used directly for `UsageBasedRateCard` (not `&MonthPeriod`).

Applied to files:

  • openmeter/productcatalog/errors.go
🧬 Code graph analysis (2)
openmeter/productcatalog/addon.go (6)
openmeter/productcatalog/featureresolver.go (1)
  • NamespacedFeatureResolver (13-16)
pkg/models/validator.go (1)
  • ValidatorFunc (10-10)
openmeter/productcatalog/addon/addon.go (1)
  • Addon (15-27)
openmeter/ent/schema/addon.go (5)
  • Addon (16-18)
  • Addon (20-24)
  • Addon (26-51)
  • Addon (53-68)
  • Addon (70-85)
openmeter/productcatalog/ratecard.go (2)
  • ValidateRateCardsWithFeatures (847-882)
  • RateCards (519-519)
openmeter/productcatalog/addon/ratecard.go (1)
  • RateCards (152-152)
openmeter/productcatalog/featureresolver.go (4)
openmeter/productcatalog/feature/connector.go (1)
  • FeatureConnector (29-36)
app/common/namespace.go (1)
  • Namespace (13-15)
pkg/pagination/page.go (1)
  • Page (14-17)
pkg/models/errors.go (2)
  • NewGenericNotFoundError (38-40)
  • NewGenericConflictError (68-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Test
  • GitHub Check: Migration Checks
  • GitHub Check: Lint
  • GitHub Check: Build
  • GitHub Check: Code Generators
  • GitHub Check: Repository Scan
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
openmeter/productcatalog/addon.go (1)

3-15: Import change looks good

Pulling in context here is exactly what you need for the new feature‑aware validator and doesn’t introduce any side effects in this file.

openmeter/productcatalog/featureresolver.go (1)

13-39: Nice, clean namespaced resolver abstraction

The NamespacedFeatureResolver interface plus the namespacedFeatureResolver implementation look straightforward and easy to use. WithNamespace reusing the same connector is a nice touch for keeping call‑sites tidy when you need to hop namespaces.

openmeter/productcatalog/errors.go (1)

104-132: New rate‑card feature errors fit the existing error model nicely

These three errors line up well with the new feature‑aware validation flow:

  • Separate codes for not found, archived, and id/key mismatch.
  • Consistent use of featureKey as the field, which will work well with the field selectors in the rate card validators.
  • Critical severity + 400 status matches the fact that these are hard blockers for publishing.

No issues from my side here.

tothandras
tothandras previously approved these changes Dec 3, 2025
@chrisgacsal
chrisgacsal merged commit 2ea4031 into main Dec 4, 2025
@chrisgacsal
chrisgacsal deleted the fix/plan-addon-feature branch December 4, 2025 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants