Skip to content

fix(api): surface rate card price errors as user-serviceable - #4979

Merged
tothandras merged 2 commits into
mainfrom
fix/api-errors
Aug 24, 2026
Merged

tothandras merged 2 commits into
mainfrom
fix/api-errors

Conversation

@tothandras

@tothandras tothandras commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Creating an addon with a non-flat price (e.g. unit) and no billing_cadence failed 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 (field billingCadence, HTTP 400 attributed) — surfaced on the draft's validation_errors and 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 api skill.

Behavior change

POST /addons with a non-flat price and no billing_cadence: previously 500; now 201 draft carrying the billing_cadence_invalid_value validation error, publish rejected with 400.

Test plan

  • Unit tests on the converters (addons + plans).
  • New e2e tests, run against the local stack built from this branch:
    • TestV3AddonUnitPriceWithoutBillingCadence — create draft → GET shows error → publish 400 → fix → publish OK
    • TestV3PlanUnitPriceWithoutBillingCadence — same flow for plans
    • TestV3RateCardUnknownPriceType — {"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.

  • Maps cadence-less non-flat addon rate cards to zero-cadence usage-based domain objects for structured validation.
  • Wraps unsupported addon and plan price discriminators as generic validation errors so API responses use HTTP 400.
  • Adds converter unit tests, draft lifecycle e2e coverage, and converter guidance.

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

Filename Overview
api/v3/handlers/addons/convert.go Converts cadence-less non-flat prices into zero-cadence usage rate cards and classifies unknown price types as validation errors.
api/v3/handlers/plans/convert.go Wraps unsupported plan price discriminators as generic validation errors for HTTP 400 handling.
api/v3/handlers/addons/convert_test.go Adds unit coverage confirming unknown addon price types produce validation errors.
api/v3/handlers/plans/convert_test.go Adds equivalent unknown-price validation coverage for plans.
e2e/addons_v3_test.go Covers addon invalid-draft validation, publish blocking and recovery, plus unknown discriminator handling.
e2e/plans_v3_test.go Covers the plan lifecycle for a non-flat rate card lacking billing cadence.

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]
Loading

Reviews (1): Last reviewed commit: "docs(skills): add converter rule to the ..." | Re-trigger Greptile

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
@tothandras
tothandras requested a review from a team as a code owner August 23, 2026 13:00
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@tothandras, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review or push new commits to the PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2397f3f0-0aaf-4cd1-8edb-85be86e9caa6

📥 Commits

Reviewing files that changed from the base of the PR and between 7e57a39 and 28a74f5.

📒 Files selected for processing (7)
  • .agents/skills/api/SKILL.md
  • api/v3/handlers/addons/convert.go
  • api/v3/handlers/addons/convert_test.go
  • api/v3/handlers/plans/convert.go
  • api/v3/handlers/plans/convert_test.go
  • e2e/addons_v3_test.go
  • e2e/plans_v3_test.go

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.

@tothandras
tothandras merged commit 5d0cc19 into main Aug 24, 2026
28 of 29 checks passed
@tothandras
tothandras deleted the fix/api-errors branch August 24, 2026 08:46
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