Errors, Security Logging, and Incident Response

A failed permission check and a failed database connection need different responses. Users need a clear outcome. Operators need enough evidence to determine whether access was denied, a dependency failed, or data changed.

On this page

Fail safely and preserve consistency

If authorization is unavailable, stop the operation. Use a transaction for related writes so a partial change rolls back. Give the user a neutral error and a request ID. Keep stack traces and database details in protected diagnostics. Retry only operations designed to be safe to repeat.

HTTP/1.1 503 Service Unavailable
Content-Type: application/json

{"message":"Could not save your changes. Try again later.","requestId":"req-57"}

Turn a security event into a response

Record structured events for significant authorization denials, permission changes, and credential rotation. Exclude passwords, tokens, and document contents. Restrict log access and retention. Give important alerts an owner. During an incident, preserve evidence, contain the affected access, recover from a known-good state, and verify the original control before closing.

{"event":"document.edit.denied","actorId":"user-7","requestId":"req-57"}
Alert owner     On-call application team
Recovery check  Revoked sessions are denied; authorized readers can reopen files

Official references