hashicorp / hashicorp/go-retryablehttp

Default backoff doesn't honour RetryWaitMax when "Retry-After" header is sent in the response

Open
#247 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
298
PR merge metrics
No merged PRs in 30d

Description

https://github.com/hashicorp/go-retryablehttp/blob/9dfd949154e507c91ee569367ffa461991b80950/client.go#L551-L566

The DefaultBackoff in function has a logical flaw when handling the `Retry-After` header. If the server provides an unreasonably high value in the Retry-After header, the function respects it without enforcing the `RetryWaitMax` limit set for the httpClient. This can lead to indefinite wait times or blocking behaviour.

### Steps to Reproduce
1. Simulate a server response with an HTTP `429 Too Many Requests` status.
2. Set a high value in the `Retry-After` header (e.g., `Retry-After: 3600` for 1 hour).
3. Observe that the backoff duration exceeds the configured `RetryWaitMax` limit.

### Expected Behaviour
I believe the backoff duration should always be bounded by the configured `RetryWaitMax` value, regardless of the `Retry-After` header value.

### Suggested Fix
Honour "Retry-After" header value only if its less than or equal to RetryWaitMax in default retry strategy
```go
if sleep <= max {
return max // Enforce max backoff limit
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.