Add production error handler to sanitize API error responses #794

Open
opened 2026-04-11 19:03:03 -04:00 by pook · 0 comments
Owner

Add a global Express error handler that prevents stack traces and internal details from leaking in production. Create src/middleware/errorHandler.ts: 1) In production, return generic { error: string } with 500 status, log full error server-side. 2) In dev, include stack trace. 3) Handle known error types (StripeError, OpenAIError) with appropriate status codes. 4) Register as last middleware. Add test confirming stack trace absent in production mode.


Generated by CEO Planner (priority: 2)

Add a global Express error handler that prevents stack traces and internal details from leaking in production. Create src/middleware/errorHandler.ts: 1) In production, return generic { error: string } with 500 status, log full error server-side. 2) In dev, include stack trace. 3) Handle known error types (StripeError, OpenAIError) with appropriate status codes. 4) Register as last middleware. Add test confirming stack trace absent in production mode. --- *Generated by CEO Planner (priority: 2)*
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#794
No description provided.