Skip to content

Conversation

@PetrDlouhy
Copy link
Contributor

@PetrDlouhy PetrDlouhy commented Dec 17, 2025

The Problem

When webhooks fail with Http404, provider dashboards show unreadable HTML:

<!DOCTYPE html><html><head><title>404 Not Found</title></head>...

This makes debugging extremely difficult - you can't tell what went wrong.

The Solution

Webhook errors now return clean JSON with context:

{"error": "Invalid payment provider", "variant": "stripe"}
{"error": "Payment not found", "variant": "paypal"}  
{"error": "Invalid signature", "variant": "stripe", "error_code": 400}

Provider dashboards now show:

  • What went wrong - clear error message
  • Which provider - variant field for multi-provider setups
  • Error code - for detailed debugging

Changes

  • Return JSON instead of raising Http404 for webhook errors
  • Add variant field to all error responses
  • Add error_code field for PaymentError responses
  • Remove token exposure from errors (security)

Breaking Change

If you catch Http404 from webhook endpoints, update to handle JSON responses with status codes (400, 404).

Note: Standard webhook systems already expect JSON - no changes needed for normal usage.

@PetrDlouhy PetrDlouhy force-pushed the feature/webhook-debug-info branch 4 times, most recently from f468406 to adbbcbe Compare December 17, 2025 13:25
@PetrDlouhy PetrDlouhy changed the title feat: Include variant and error_code in webhook error responses feat: Return JSON error responses from webhook endpoints Dec 17, 2025
When webhooks fail with Http404, provider dashboards show unreadable HTML.
This change returns clean JSON with context for easier debugging.

Changes:
- Return JSON instead of raising Http404 for webhook errors
- Add 'variant' field to all error responses
- Add 'error_code' field for PaymentError responses
- Remove token exposure from errors (security improvement)

BREAKING CHANGE: Webhook endpoints now return JSON responses with status
codes (400, 404) instead of raising Http404 exceptions. If you have custom
code catching Http404 from webhook endpoints, update to handle JSON responses.

Standard webhook systems (Stripe, PayPal) already expect JSON - no changes
needed for normal usage.
@PetrDlouhy PetrDlouhy force-pushed the feature/webhook-debug-info branch from adbbcbe to bbf3cb4 Compare December 17, 2025 13:33
@PetrDlouhy PetrDlouhy marked this pull request as ready for review December 17, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant