The branching pattern
The canonical branching pattern in pseudocode:- Never branch on
error.message— it is unstable. - Always inspect
error.details[]before treating an error as terminal — the specificreasonoften dictates a different recovery path.
Concrete examples
Retry semantics by status
Apply this table without modification — it is the standard.
Detailed retry mechanics in Retry strategy.
Idempotency on retry
When you do retry —RESOURCE_EXHAUSTED, provider/database/upstream UNAVAILABLE, or the one-shot retry after REPLAY_DETECTED — keep these stable across attempts:
The signer should be designed so that only the body bytes feed into the canonical request as content; everything else is fresh per attempt.
Logging recommendations
For every non-2xx response, log at minimum:- HTTP method and URL (without secret query-string values).
error.statusanderror.code.- Every
details[].reason. metadata.decisionIdif present.metadata.idfromERROR_RECORDEDif present.- The full
details[]array as structured JSON (designed to be safe to log). - Approximate UTC time of the request.
- Your
X-Access-Request-Id(your correlation handle).
Next
Retry strategy
The exact backoff formula and limits.
Error catalog
Every reason code with HTTP status and remediation.