Decide the error handling for a new API endpoint
I'm adding an endpoint: {{method, path, what it does}}. It touches {{database / third-party API / queue}}. Callers are {{our own frontend / third-party integrators / both}}.
Give me a table of every failure mode, with: the trigger, the status code, the response body shape, whether it's retryable, whether the caller should back off, and what we log at what level.
Cover at minimum: invalid input, missing auth, insufficient permission, resource not found versus not visible to this caller, conflict with concurrent writes, downstream timeout, downstream 5xx, rate limit hit, and partial success.
Then answer three things directly: which of these should be idempotent-safe to retry, where we're at risk of leaking whether a resource exists to someone not allowed to see it, and which single failure mode we're most likely to get wrong on the first implementation.
How to use it
The 404-versus-403 row is where security bugs hide. Decide it before you write the handler, not during review.
Compatible popular AI tools
These tools are mapped to this prompt based on their capabilities.
People who liked this prompt
2 community likes