Skip to content

[CORE] Introduce centralized error-handling middleware for security hardening #157

Description

@adityakrmishra

Description

API routes and webhook handlers currently manage errors via disparate try/catch blocks. This lack of centralization creates a security risk where stack traces, internal database states, or environment variables could be leaked to the client during unhandled exceptions.

Proposed Solution

  • Middleware Pattern: Create a higher-order wrapper function withErrorHandler in src/lib/middleware/.
  • Sanitization: Implement logic that catches unhandled exceptions, sanitizes paths/stack traces, and scrubs process.env matches.
    -Implementation: Wrap all exported GET and POST handlers in API routes with this middleware to ensure a uniform, secure JSON error response across the entire backend architecture.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions