Fix: API client errors return JSON, not HTML
Web-audit fix skill for the
json-errorscheck (API, SHOULD).
Goal
Return a JSON error body on client-error API responses so agents can parse the failure.
Fix
On a client-error API response (4xx), return Content-Type: application/json and a JSON object (for example { "error": { "code": "not_found", "message": "..." } }), not an HTML error page. Agents cannot recover from a soft-HTML 404. The audit probes a documented OpenAPI 4xx GET when one exists, otherwise GET /anc-web-audit-no-such-api.
Resources
Copy-paste prompt
Paste this into your coding agent. Your audit adds what it observed for this check:
Verify
Re-run the audit at https://anc.dev/audit or call the audit_website MCP tool; the json-errors check should report pass.