---
title: "Show short errors · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities/short-errors
id: APS-78
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 786
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Show short errors

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Errors, logs and vulnerabilities](https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-78
- Level: Recommended
- Chapter: [Errors, logs and vulnerabilities](https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities.md)
- Rule: Show visitors a short error with a reference number. Keep stack traces, queries and file paths in the server log.
- Check: The agent sends broken input, such as a quote in a search box or invalid JSON to an API. The reply has no stack trace, query, path or version number.
- How: Catch every error in one place. Log the full detail with a random reference, and return a plain message with that reference. Turn off debug mode in production. For API error bodies, see [no internal details](https://agentwranglers.se/playbook/api-design/errors/no-internal-details.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JSON example

```json
{ "error": "Something went wrong. Reference: 7f3c2a" }
```

### JavaScript example

```js
// Express: one error handler, last in the chain
app.use((err, req, res, next) => {
  const reference = crypto.randomUUID().slice(0, 8);
  log.error({ reference, err });
  res.status(500).json({ error: `Something went wrong. Reference: ${reference}` });
});
```

### Python example

```python
# Python with Flask: 500 catches every error the code did not handle
@app.errorhandler(500)
def handle_error(error):
    reference = secrets.token_hex(4)
    app.logger.exception("reference=%s", reference)
    return {"error": f"Something went wrong. Reference: {reference}"}, 500
```

## Sources

- [OWASP Error Handling Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html)

## Related rules

- WEB-220 [Make error pages helpful and honest](https://agentwranglers.se/playbook/website/errors-and-outages/error-pages.md) in Website
- API-19 [Hide internals in errors](https://agentwranglers.se/playbook/api-design/errors/no-internal-details.md) in API design

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities/short-errors">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Keep private data out of logs and addresses](https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities/private-data-out-of-logs.md)
- [Errors, logs and vulnerabilities](https://agentwranglers.se/playbook/application-security/errors-logs-and-vulnerabilities.md)
