go.http_retry
Stability
Medium
Detects HTTP client calls without retry logic, which fail on transient network issues.
Why It Matters
Section titled “Why It Matters”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
Example
Section titled “Example”// ❌ 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 } // ...}What Unfault Detects
Section titled “What Unfault Detects”- HTTP GET/POST without retry wrapper
- Missing retry on 5xx responses
- Missing retry on connection errors
- Direct
http.Clientusage without retry policy
Auto-Fix
Section titled “Auto-Fix”Unfault generates patches using go-retryablehttp:
import "github.com/hashicorp/go-retryablehttp"
client := retryablehttp.NewClient()client.RetryMax = 3client.RetryWaitMin = 1 * time.Secondclient.RetryWaitMax = 30 * time.Second