Which HTTP errors should you retry, and which should you not?
IntermediateConceptData formats, HTTP & REST APIs
Answer
Retry: connection errors, timeouts, 429 (honor Retry-After), 502, 503, 504, and usually 500 for idempotent calls.
Do not retry: 400 (your request is wrong), 401/403 (credentials or permissions; retrying can lock accounts), 404, 409 conflicts (handle explicitly), 422 validation errors.
Retrying non-idempotent POSTs can create duplicates (two deployments, two tickets), unless the API supports an idempotency key header.
More on Data formats, HTTP & REST APIs
How do you read and write JSON, and what are the common gotchas?BeginnerWhy must you use `yaml.safe_load` rather than `yaml.load`?BeginnerHow do you load a multi-document Kubernetes YAML file?IntermediateHow do you read and write CSV files properly?BeginnerHow do you make an HTTP request with `requests` the right way?BeginnerWhy use a `requests.Session`?Intermediate