From 6cc779eb1adef76d9af9bf1aaa1505742add5063 Mon Sep 17 00:00:00 2001 From: Keepers Date: Wed, 3 May 2023 16:10:27 -0600 Subject: [PATCH] additional middleware segfault protection (#3296) gotta catch 'em all --- #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :bug: Bugfix #### Issue(s) * #3285 #### Test Plan - [x] :green_heart: E2E --- src/internal/connector/graph/middleware.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/internal/connector/graph/middleware.go b/src/internal/connector/graph/middleware.go index 4954b0b47..7bd64fa38 100644 --- a/src/internal/connector/graph/middleware.go +++ b/src/internal/connector/graph/middleware.go @@ -227,17 +227,24 @@ func (mw RetryMiddleware) retryRequest( exponentialBackoff *backoff.ExponentialBackOff, priorErr error, ) (*http.Response, error) { - ctx = clues.Add(ctx, "retry_count", executionCount) + status := "unknown_resp_status" + statusCode := -1 if resp != nil { - ctx = clues.Add(ctx, "prev_resp_status", resp.Status) + status = resp.Status + statusCode = resp.StatusCode } + ctx = clues.Add( + ctx, + "prev_resp_status", status, + "retry_count", executionCount) + // only retry under certain conditions: // 1, there was an error. 2, the resp and/or status code match retriable conditions. // 3, the request is retriable. // 4, we haven't hit our max retries already. - if (priorErr != nil || mw.isRetriableRespCode(ctx, resp, resp.StatusCode)) && + if (priorErr != nil || mw.isRetriableRespCode(ctx, resp, statusCode)) && mw.isRetriableRequest(req) && executionCount < mw.MaxRetries { executionCount++