Skip to content

Revert "fix(productcatalog): rate card validation"#4276

Merged
tothandras merged 1 commit into
mainfrom
revert-4268-fix/rate-card-validation
May 4, 2026
Merged

Revert "fix(productcatalog): rate card validation"#4276
tothandras merged 1 commit into
mainfrom
revert-4268-fix/rate-card-validation

Conversation

@chrisgacsal
Copy link
Copy Markdown
Collaborator

@chrisgacsal chrisgacsal commented May 4, 2026

Reverts #4268

Summary by CodeRabbit

Release Notes

  • Refactor

    • Simplified rate card validation logic to allow usage-based pricing models to be configured without requiring feature associations, providing greater flexibility in pricing setup.
  • Tests

    • Updated test fixtures and helper functions to reflect simplified rate card configuration requirements.

@chrisgacsal chrisgacsal requested a review from a team as a code owner May 4, 2026 08:08
@chrisgacsal chrisgacsal added the release-note/ignore Ignore this change when generating release notes label May 4, 2026
@chrisgacsal chrisgacsal enabled auto-merge (squash) May 4, 2026 08:09
@tothandras tothandras disabled auto-merge May 4, 2026 08:09
@tothandras tothandras merged commit d473249 into main May 4, 2026
25 of 28 checks passed
@tothandras tothandras deleted the revert-4268-fix/rate-card-validation branch May 4, 2026 08:09
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c25ab24-23ad-4cc4-9869-c6d1a002951f

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac96d9 and 6503ee9.

📒 Files selected for processing (14)
  • e2e/addons_v3_test.go
  • e2e/config.yaml
  • e2e/e2e_test.go
  • e2e/v3helpers_test.go
  • openmeter/productcatalog/addon/service/addon.go
  • openmeter/productcatalog/errors.go
  • openmeter/productcatalog/plan/adapter/adapter_test.go
  • openmeter/productcatalog/plan/adapter/mapping.go
  • openmeter/productcatalog/plan/service/plan.go
  • openmeter/productcatalog/ratecard.go
  • openmeter/productcatalog/ratecard_test.go
  • openmeter/subscription/addon/diff/restore_test.go
  • openmeter/subscription/repo/mapping.go
  • openmeter/subscription/workflow/service/addon_test.go

📝 Walkthrough

Walkthrough

This PR removes the validation requirement that usage-based rate cards must reference a metered feature. The change eliminates related error definitions, validation logic in rate card metadata and service resolution paths, test fixtures, and backfill logic that previously populated missing feature keys from eager-loaded data.

Changes

Feature Reference Decoupling for Rate Cards

Layer / File(s) Summary
Error Definitions
openmeter/productcatalog/errors.go
Removed two exported validation errors: ErrRateCardUsageBasedPriceRequiresFeatureKey and ErrRateCardUsageBasedPriceRequiresMeteredFeature.
Core Validation
openmeter/productcatalog/ratecard.go
Removed conditional in RateCardMeta.Validate that rejected non-flat prices without a feature reference.
Service Resolution
openmeter/productcatalog/addon/service/addon.go, openmeter/productcatalog/plan/service/plan.go
Removed metering eligibility checks in resolveFeatures; now only validates feature existence and merges missing IDs/keys without checking price type against MeterID.
Adapter/Mapping Cleanup
openmeter/productcatalog/plan/adapter/mapping.go
Removed backfill logic that populated FeatureKey from eagerly-loaded Features edges in both addon and plan rate-card mapping paths.
Test Fixtures & Setup
e2e/v3helpers_test.go
Refactored validUnitRateCard and validGraduatedRateCard to accept a keyPrefix instead of feature ID/key, and removed feature associations from returned rate cards.
Subscription Test Mappings
openmeter/subscription/repo/mapping.go
Removed fallback logic that backfilled FeatureKey from RateCardMeta.Key in subscription item mapping.
E2E & Unit Tests
e2e/addons_v3_test.go, e2e/v3helpers_test.go, openmeter/productcatalog/ratecard_test.go, openmeter/productcatalog/plan/adapter/adapter_test.go, openmeter/subscription/addon/diff/restore_test.go, openmeter/subscription/workflow/service/addon_test.go
Removed feature creation setup, updated test cases to use new keyed helpers without feature references, and replaced fixture keys with explicit string literals ("dynamic_rc_1", "addon_dynamic_rc", etc.).
Config & Misc E2E Updates
e2e/config.yaml, e2e/e2e_test.go
Completed plan_meter configuration, removed addon_meter entry, and updated feature list query to use context.Background() without meter slug filter.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Suggested Labels

release-note/misc, area/product-catalog, area/subscriptions

Suggested Reviewers

  • tothandras
✨ 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 revert-4268-fix/rate-card-validation

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

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

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants