You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`UNPROCESSABLE` - Business logic violation (e.g., cannot delete last admin)
51
57
52
58
### 429 Too Many Requests
59
+
53
60
-`RATE_LIMITED` - Rate limit exceeded
54
61
55
62
### 500 Internal Server Error
63
+
56
64
-`INTERNAL_ERROR` - Unexpected server error (safe message, no stack traces)
57
65
58
66
## Example Error Responses
@@ -171,16 +179,26 @@ Examples:
171
179
172
180
## Security Considerations
173
181
182
+
### PII and Internal Detail Sanitization
183
+
184
+
In production environments (`NODE_ENV=production`), all error responses are automatically sanitized to prevent the leakage of sensitive information. This includes:
185
+
186
+
-**Internal Error Details**: For `500 Internal Server Error` responses, the original error message and stack trace are logged internally but are **never** included in the JSON response body. The client receives a generic "Internal server error" message.
187
+
-**PII Redaction**: For validation errors (HTTP 400) that might echo back parts of the request payload in the `details` field, any values matching the PII taxonomy (e.g., email addresses, wallet addresses, sensitive keys) are automatically redacted.
188
+
-**Correlation ID**: The `requestId` is always preserved, allowing for secure error correlation between the client and server-side logs.
189
+
190
+
In non-production environments, error messages may contain more detail to aid in debugging.
191
+
174
192
1.**No Stack Traces**: Stack traces are never exposed in production error responses
175
193
2.**No Secrets**: Error messages never include tokens, API keys, database credentials, or raw SQL
176
194
3.**Safe Messages**: Internal errors return generic "Internal server error" messages to prevent information leakage
177
-
4.**Structured Logging**: Errors are logged server-side with full context for debugging
178
195
179
196
## Client Integration Guidelines
180
197
181
198
### Handling Errors
182
199
183
200
Clients should:
201
+
184
202
1. Check the HTTP status code first
185
203
2. Use the `code` field for programmatic error handling (not the message)
186
204
3. Display the `message` field to users
@@ -196,40 +214,40 @@ interface ApiError {
196
214
message:string;
197
215
details?:Record<string, unknown>;
198
216
requestId?:string;
199
-
}
217
+
};
200
218
}
201
219
202
220
asyncfunction apiCall():Promise<void> {
203
-
const response =awaitfetch('/api/resource', {
221
+
const response =awaitfetch("/api/resource", {
204
222
headers: {
205
-
'x-request-id': generateRequestId() // For traceability
206
-
}
223
+
"x-request-id": generateRequestId(),// For traceability
0 commit comments