Skip to content

Commit 966ea48

Browse files
committed
fix(client):extend retry logic
1 parent c6b1176 commit 966ea48

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

internal/client/client.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ type Client struct {
2828
httpClient *http.Client
2929
}
3030

31+
var retryableStatusCodes = map[int]bool {
32+
http.StatusBadGateway: true,
33+
http.StatusGatewayTimeout: true,
34+
http.StatusInternalServerError: true,
35+
http.StatusServiceUnavailable: true,
36+
// as of (2026-01-21) we believe there can be erronus responses from the API of 400 bad request that we wish to retry on
37+
http.StatusBadRequest: true,
38+
}
39+
3140
func New(cfg *config.Config) (*Client, error) {
3241
httpClient := http.DefaultClient
3342
if cfg.SslCaCert != "" {
@@ -139,7 +148,7 @@ func (c *Client) doRequest(method, path string, body []byte) ([]byte, error) {
139148
return err
140149
}
141150

142-
if resp.StatusCode == http.StatusInternalServerError {
151+
if retryableStatusCodes[resp.StatusCode] {
143152
resp.Body.Close()
144153
return fmt.Errorf("non-ok response from api: %s", resp.Status)
145154
}

0 commit comments

Comments
 (0)