Repository navigation
fix(api): surface rate card price errors as user-serviceable - #4979
Conversation
The v3 addon rate card converter rejected non-flat prices without billing_cadence with a bare error, which surfaced as a 500. Convert the body faithfully instead: such rate cards map to a zero-cadence usage-based rate card and the domain validation reports billing_cadence_invalid_value on the draft and blocks publish, matching the plans behavior. Unknown price type discriminators cannot be mapped at all; wrap those converter errors as validation errors so they return 400 instead of 500. Claude-Session: https://claude.ai/code/session_01S93A9RigLLfBnXoauNNt7w
|
Warning Review limit reached
Next review available in: 10 minutes Limit details: You’ve used all 8 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
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 |
Summary
Creating an addon with a non-flat price (e.g.
unit) and nobilling_cadencefailed with a 500 (unsupported price type "unit" for flat fee rate card) instead of a user-serviceable error.The v3 addon rate card converter enforced this price-type restriction itself with a bare error. Converters should map the body to the service type faithfully and leave validation to the service: such rate cards now map to a zero-cadence usage-based rate card, and domain validation reports
billing_cadence_invalid_value(fieldbillingCadence, HTTP 400 attributed) — surfaced on the draft'svalidation_errorsand blocking publish, matching the existing plans behavior.Unknown price type discriminators cannot be mapped at all; those converter errors are now wrapped as validation errors so they return 400 instead of 500 (addons + plans).
Also records the converter rule in the
apiskill.Behavior change
POST /addonswith a non-flat price and nobilling_cadence: previously 500; now 201 draft carrying thebilling_cadence_invalid_valuevalidation error, publish rejected with 400.Test plan
TestV3AddonUnitPriceWithoutBillingCadence— create draft → GET shows error → publish 400 → fix → publish OKTestV3PlanUnitPriceWithoutBillingCadence— same flow for plansTestV3RateCardUnknownPriceType—{"type":"bogus"}price → 400 on addon and plan create🤖 Generated with Claude Code
https://claude.ai/code/session_01S93A9RigLLfBnXoauNNt7w
Greptile Summary
The PR makes v3 rate-card conversion preserve non-flat prices without billing cadence as invalid drafts and classifies unknown price discriminators as client validation errors.
Confidence Score: 5/5
The PR appears safe to merge with the intended invalid-draft and HTTP 400 behavior covered end to end.
The changed converters preserve cadence validation for the domain layer, prevent invalid drafts from being published, and correctly classify unknown price discriminators without introducing a reachable blocking failure.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Rate card request] --> B{Price discriminator known?} B -- No --> C[Generic validation error] C --> D[HTTP 400] B -- Yes --> E{Non-flat price without cadence?} E -- Yes --> F[Zero-cadence usage rate card] F --> G[Persist invalid draft] G --> H[Expose validation error] H --> I[Block publish] E -- No --> J[Normal rate-card conversion]Reviews (1): Last reviewed commit: "docs(skills): add converter rule to the ..." | Re-trigger Greptile