API-19Required
Hide internals in errors
Never put stack traces, queries, file paths or server versions in an error. Log them, and return a reference the client can quote.
How to do it
Map unexpected exceptions to a 500 problem with a generic title and the request ID. See short errors.
How to check
Force a server error in staging. The body holds only the problem fields and a reference, and the log holds the trace under that reference.
Sources
- OWASP Error Handling Cheat Sheet
- CWE-209 Generation of Error Message Containing Sensitive Information
Related rules
- OPS-7 Tie every line to its request in Operations and observability
- APS-78 Show short errors in Application security
- API-85 Give every GraphQL error a stable code in API design
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/errors/no-internal-details">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.