---
title: "Show short errors · Agent Wranglers"
url: https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/short-errors
updated: 2026-10-20
licence: "All rights reserved"
---

# Show short errors

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Data and secrets](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets)
- Rule: Show visitors a short error with a reference number. Keep stack traces, queries and file paths in the server log.
- 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).
- 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.

Example:

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

```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
# 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
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers security testing playbook: https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/short-errors`.

- Previous: [Keep secrets out of the browser](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/secrets-out-of-browser)
- Next: [Close debug and admin doors](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/close-debug-doors)
- [Data and secrets](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets)
