Skip to content

go.http_retry

Stability Medium

Detects HTTP client calls without retry logic, which fail on transient network issues.

Without retries:

  • Transient failures become permanent — Network blips cause request failures
  • Poor user experience — Users see errors for recoverable issues
  • Reduced reliability — 99.9% uptime requires handling temporary failures
  • Cascading issues — One failed request may abort entire workflows
// ❌ Before (no retry)
func fetchUser(id string) (*User, error) {
resp, err := http.Get(fmt.Sprintf("/users/%s", id))
if err != nil {
return nil, err // Fails on first transient error
}
// ...
}
// ✅ After (with retry)
import "github.com/hashicorp/go-retryablehttp"
var client = retryablehttp.NewClient()
func fetchUser(id string) (*User, error) {
resp, err := client.Get(fmt.Sprintf("/users/%s", id))
if err != nil {
return nil, err
}
// ...
}
  • HTTP GET/POST without retry wrapper
  • Missing retry on 5xx responses
  • Missing retry on connection errors
  • Direct http.Client usage without retry policy

Unfault generates patches using go-retryablehttp:

import "github.com/hashicorp/go-retryablehttp"
client := retryablehttp.NewClient()
client.RetryMax = 3
client.RetryWaitMin = 1 * time.Second
client.RetryWaitMax = 30 * time.Second