Repository navigation
feat: unit config authoring on v3 api - OM-396 - #4604
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 (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughAdds bidirectional UnitConfig conversion for billing rate cards, preserves stored UnitConfig during API conversion, propagates it through plan/addon adapter mappings, and adds validation that rejects UnitConfig on non-usage-based prices. ChangesUnitConfig propagation and validation
Sequence Diagram(s)sequenceDiagram
participant Handler
participant FromAPIBillingRateCard
participant FromAPIBillingUnitConfig
participant ToAPIBillingRateCard
participant ToAPIBillingUnitConfig
Handler->>FromAPIBillingRateCard: rc with UnitConfig
FromAPIBillingRateCard->>FromAPIBillingUnitConfig: api.BillingUnitConfig
FromAPIBillingUnitConfig-->>FromAPIBillingRateCard: *productcatalog.UnitConfig
FromAPIBillingRateCard-->>Handler: meta.UnitConfig set
Handler->>ToAPIBillingRateCard: domain RateCard
ToAPIBillingRateCard->>ToAPIBillingUnitConfig: productcatalog.UnitConfig (if stored)
ToAPIBillingUnitConfig-->>ToAPIBillingRateCard: api.BillingUnitConfig
ToAPIBillingRateCard-->>Handler: API rate card with UnitConfig
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Greptile SummaryThis PR adds unit config support to v3 plan authoring and related product catalog mappings. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "feat: unit config authoring on v3" | Re-trigger Greptile |
|
As the feature is still work in progress and behind a config flag, for now I relied mostly on unit test coverage but for sanity check I created an e2e test with hurl and tested that the v3 unit config authoring works e2e. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@api/v3/handlers/plans/convert_test.go`:
- Around line 729-836: Add a write-path test for FromAPIBillingRateCard in
TestUnitConfigMapping so the v3 authoring flow is covered, not just the helper
round-trips and ToAPIBillingRateCard. Create a subtest that builds an
api.BillingRateCard with unit_config, calls FromAPIBillingRateCard, and asserts
the resulting meta via AsMeta() still contains the same UnitConfig fields. This
directly verifies the copy behavior in FromAPIBillingRateCard and will catch
regressions if rc.UnitConfig is no longer propagated into meta.UnitConfig.
🪄 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: f2738161-fd96-43fb-aadb-2861be9b01da
📒 Files selected for processing (9)
api/v3/handlers/plans/convert.goapi/v3/handlers/plans/convert_test.goopenmeter/productcatalog/addon/adapter/adapter_test.goopenmeter/productcatalog/addon/adapter/mapping.goopenmeter/productcatalog/errors.goopenmeter/productcatalog/plan/adapter/adapter_test.goopenmeter/productcatalog/plan/adapter/mapping.goopenmeter/productcatalog/ratecard.goopenmeter/productcatalog/ratecard_test.go
33872c6 to
a7698d8
Compare
| priceAllowsUnitConfig := r.Price != nil && | ||
| (r.Price.Type() == UnitPriceType || r.Price.Type() == TieredPriceType) | ||
| if !priceAllowsUnitConfig { | ||
| errs = append(errs, ErrRateCardUnitConfigRequiresUsageBasedPrice) | ||
| } |
There was a problem hiding this comment.
I can imagine that this might be used at other places, so it might worth just adding a SupportsUnitConfig() (bool) to the Price interface, that delegates it to the downstream pricers.
There was a problem hiding this comment.
good idea, i'll add it to the next pr
a7698d8 to
2614d7e
Compare
Overview
Wires unit_config through the v3 plan create/update path, all gated behind the dark unitConfig.enabled flag, plus a fix for the OM-395 adapter mappers that dropped unit_config on expanded plan/add-on relations.
Note to reviewers
Summary by CodeRabbit