-
-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
Description
Context
The current error helpers (responses.error and errors.getMessage) are widely used across controllers.
During a review, we found API-contract and security weaknesses:
responses.errorincludeserror: JSON.stringify(error)in client responses.codeis overloaded between HTTP status and domain error code.- status fallback may rely on non-numeric
error.code. errors.getMessagecan fall back to raw JSON serialization of unknown errors.
Problem
This behavior can leak internal implementation details (stack traces, DB driver errors, internal objects) and makes error handling less predictable for API consumers.
Expected behavior
- Client responses must not expose raw internal error objects.
- Error payload shape must be stable and explicit.
- HTTP status and domain error code must be separated.
- Unknown errors should return a safe generic message.
Proposed direction
- Harden
responses.errorpayload contract. - Remove or gate raw serialized error output from public responses.
- Keep a stable
status(number) andcode(domain string) model. - Update
errors.getMessagefallback to a safe generic message (no raw JSON dump). - Add tests for helper behavior (AppError, validation error, unknown error).
Acceptance criteria
- No raw
JSON.stringify(error)in production API responses. - Error responses keep backward-compatible keys when possible (
type,message,description) while making status/code semantics explicit. - All unknown/internal errors return a sanitized client message.
- Unit tests cover
responses.erroranderrors.getMessageedge cases.
Reactions are currently unavailable