fix: invoice error mapping so Stripe 4xx responses are not returned as 500 #17

Merged
hodlbod merged 1 commits from userAdityaa/caravel:error-mapping into master 2026-04-16 15:39:36 +00:00
Contributor

Description

This PR fixes incorrect error translation in invoice endpoints. Previously, Stripe invoice fetch failures were collapsed into internal server error responses, even when Stripe returned client-relevant statuses like 404.

What changed

  • Added a typed invoice lookup error in billing to preserve Stripe client status codes for invoice fetches.

  • Updated invoice lookup flow to propagate that typed error to API handlers.

  • Added API-level mapping for invoice lookup failures:

    • Stripe 404 -> API 404 not found
    • Stripe 401 or 403 -> API 403 forbidden
    • Other Stripe 4xx -> API client error with preserved status
    • Unexpected failures -> API 500 internal
  • Updated both invoice read endpoints to use the new mapper.

closes #15

### Description This PR fixes incorrect error translation in invoice endpoints. Previously, Stripe invoice fetch failures were collapsed into internal server error responses, even when Stripe returned client-relevant statuses like 404. ### What changed * Added a typed invoice lookup error in billing to preserve Stripe client status codes for invoice fetches. * Updated invoice lookup flow to propagate that typed error to API handlers. * Added API-level mapping for invoice lookup failures: * Stripe 404 -> API 404 not found * Stripe 401 or 403 -> API 403 forbidden * Other Stripe 4xx -> API client error with preserved status * Unexpected failures -> API 500 internal * Updated both invoice read endpoints to use the new mapper. closes #15
userAdityaa added 1 commit 2026-04-16 09:32:25 +00:00
hodlbod merged commit bac763c925 into master 2026-04-16 15:39:36 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/caravel#17