Improve Stripe error mapping for invoice fetches #15

Closed
opened 2026-04-15 13:51:42 +00:00 by userAdityaa · 0 comments
Contributor

Problem

Invoice fetch failures from Stripe are currently surfaced as internal server errors. A missing invoice, permission issue, or other 4xx from Stripe is collapsed into a generic 500, which makes the API response misleading and harder for clients to handle correctly.

Current behavior

  • Billing::stripe_get_invoice calls Stripe and uses error_for_status()
  • Any non-2xx Stripe response becomes an error
  • api::get_invoice converts that error into ApiError::Internal
  • Clients receive a 500 even when Stripe returned a 404 or another client-relevant status

Expected behavior

  • Stripe 404 for a missing invoice should return a not-found response
  • Other Stripe 4xx responses should be mapped to an appropriate client error
  • Only unexpected failures should become 500s
### Problem Invoice fetch failures from Stripe are currently surfaced as internal server errors. A missing invoice, permission issue, or other 4xx from Stripe is collapsed into a generic 500, which makes the API response misleading and harder for clients to handle correctly. ### Current behavior - `Billing::stripe_get_invoice` calls Stripe and uses `error_for_status()` - Any non-2xx Stripe response becomes an error - `api::get_invoice` converts that error into `ApiError::Internal` - Clients receive a 500 even when Stripe returned a 404 or another client-relevant status ### Expected behavior - Stripe 404 for a missing invoice should return a not-found response - Other Stripe 4xx responses should be mapped to an appropriate client error - Only unexpected failures should become 500s
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/caravel#15