Add structured 403 error response when subscription gate rejects /api/generate requests #1376

Open
opened 2026-04-13 16:14:54 -04:00 by pook · 0 comments
Owner

When the subscription gate middleware rejects a request to POST /api/generate, return a structured JSON response that the frontend can use to prompt upgrade.

Steps:

  1. Find the subscription gate middleware (related to PR #705)
  2. Ensure rejected requests return: status 403, body { error: 'subscription_required', message: 'Active subscription required to generate documents.', upgradeUrl: '/api/billing/checkout' }
  3. Log the rejection at info level with user email (for analytics on conversion funnel)
  4. Verify no Stripe internal error details leak to the client
  5. Add a test: unauthenticated/unpaid request to /api/generate returns 403 with correct JSON shape

Acceptance: 403 response has consistent JSON structure. Frontend can detect subscription_required and redirect to checkout. No Stripe internals exposed.


Generated by CEO Planner (priority: 3)

When the subscription gate middleware rejects a request to POST /api/generate, return a structured JSON response that the frontend can use to prompt upgrade. Steps: 1. Find the subscription gate middleware (related to PR #705) 2. Ensure rejected requests return: status 403, body `{ error: 'subscription_required', message: 'Active subscription required to generate documents.', upgradeUrl: '/api/billing/checkout' }` 3. Log the rejection at info level with user email (for analytics on conversion funnel) 4. Verify no Stripe internal error details leak to the client 5. Add a test: unauthenticated/unpaid request to /api/generate returns 403 with correct JSON shape Acceptance: 403 response has consistent JSON structure. Frontend can detect subscription_required and redirect to checkout. No Stripe internals exposed. --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1376
No description provided.