From 547a2b7d612a3b4f1efb3d0840d821a9d22aa320 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Fri, 19 Apr 2024 13:45:19 +0100 Subject: [PATCH] sdk/client: conditionally return the error when the resp is nil whilst retrying the request, see https://github.com/manicminer/hamilton/pull/280 --- sdk/client/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/client/client.go b/sdk/client/client.go index 29102933c37..52fb5e6aead 100644 --- a/sdk/client/client.go +++ b/sdk/client/client.go @@ -71,7 +71,11 @@ func RequestRetryAll(retryFuncs ...RequestRetryFunc) func(resp *http.Response, o // RetryableErrorHandler simply returns the resp and err, this is needed to make the Do() method // of retryablehttp client return early with the response body not drained. func RetryableErrorHandler(resp *http.Response, err error, _ int) (*http.Response, error) { - return resp, err + if resp == nil { + return nil, err + } + + return resp, nil } // Request embeds *http.Request and adds useful metadata