fix: validating metered feature for ubp ratecard#4502
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughRefactors rate-card feature handling into a RateCardFeature interface; updates adapters to eager-load and backfill features when referenced; enforces that usage-based rate cards with a feature have a MeterID; updates related tests and adds a Plan Repository interface plus minor cleanups. ChangesRateCard Feature Refactoring with Meter Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
openmeter/productcatalog/addon/adapter/addon.go (1)
555-561: ⚡ Quick winInline these tiny eager-load wrappers.
On Line 555 and Line 559, these helpers only wrap one query call each, so they add indirection without adding domain meaning. Inlining both calls back into
AddonEagerLoadRateCardsFnkeeps this path easier to scan.As per coding guidelines, "
**/*.go: In Go code, do not extract helper functions only to hide a couple of simple operations or short guard checks; prefer inline code when the helper would only wrap 2-4 lines and its name does not add meaningful domain intent."🤖 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 `@openmeter/productcatalog/addon/adapter/addon.go` around lines 555 - 561, Remove the tiny wrappers rateCardEagerLoadFeaturesFn and rateCardEagerLoadTaxCodesFn and inline their single calls into AddonEagerLoadRateCardsFn: replace usages of those helper vars with direct q.WithFeatures() and q.WithTaxCode() inside the AddonEagerLoadRateCardsFn implementation, and delete the now-unused variables to eliminate unnecessary indirection.Source: Coding guidelines
🤖 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 `@openmeter/productcatalog/featureresolver/resolver_test.go`:
- Around line 166-167: The test is dereferencing potentially nil values (`f` and
entries in `resolved`) after non-fatal asserts which can cause panics; add
explicit nil guards using require.NotNil before any field access. Concretely,
before calls that use lo.FromPtr(f.MeterID) / lo.FromPtr(f.MeterSlug) insert
require.NotNil(t, f) (or require.NotNil(t, resolved[k]) where applicable), then
keep the assert.Equalf checks; apply the same change to the other block that
inspects resolved[k] (the assertions using lo.FromPtr on MeterID/MeterSlug).
---
Nitpick comments:
In `@openmeter/productcatalog/addon/adapter/addon.go`:
- Around line 555-561: Remove the tiny wrappers rateCardEagerLoadFeaturesFn and
rateCardEagerLoadTaxCodesFn and inline their single calls into
AddonEagerLoadRateCardsFn: replace usages of those helper vars with direct
q.WithFeatures() and q.WithTaxCode() inside the AddonEagerLoadRateCardsFn
implementation, and delete the now-unused variables to eliminate unnecessary
indirection.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cf5cbaac-5e63-4195-861b-335c5984e29c
📒 Files selected for processing (13)
openmeter/productcatalog/addon/adapter/addon.goopenmeter/productcatalog/addon/adapter/mapping.goopenmeter/productcatalog/errors.goopenmeter/productcatalog/featureresolver/ratecard.goopenmeter/productcatalog/featureresolver/resolver_test.goopenmeter/productcatalog/plan/adapter/mapping.goopenmeter/productcatalog/plan/adapter/plan.goopenmeter/productcatalog/plan/repository.goopenmeter/productcatalog/plan/service/plan.goopenmeter/productcatalog/ratecard.goopenmeter/subscription/addon/diff/apply_test.goopenmeter/subscription/addon/extend_test.goopenmeter/subscription/workflow/service/addon_test.go
💤 Files with no reviewable changes (1)
- openmeter/productcatalog/plan/repository.go
d52c1e0 to
3794b49
Compare
3794b49 to
c77ac56
Compare
Overview
Ensure that ratecards with usage-based pricing have metered feature.
Summary by CodeRabbit
Bug Fixes
Refactor