diff --git a/src/internal/connector/graph/retry_middleware.go b/src/internal/connector/graph/retry_middleware.go index 1d66a2e81..371502a59 100644 --- a/src/internal/connector/graph/retry_middleware.go +++ b/src/internal/connector/graph/retry_middleware.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/clues" backoff "github.com/cenkalti/backoff/v4" khttp "github.com/microsoft/kiota-http-go" ) @@ -50,7 +50,10 @@ func (middleware RetryHandler) retryRequest( response, err := pipeline.Next(req, middlewareIndex) if err != nil && !IsErrTimeout(err) { - return response, support.ConnectorStackErrorTraceWrap(err, "maximum retries or unretryable") + return response, clues.Stack(err). + WithClues(ctx). + With("retry_count", executionCount). + With(ErrData(err)...) } return middleware.retryRequest(ctx, @@ -64,7 +67,14 @@ func (middleware RetryHandler) retryRequest( err) } - return resp, support.ConnectorStackErrorTraceWrap(respErr, "maximum retries or unretryable") + if respErr != nil { + return nil, clues.Stack(respErr). + WithClues(ctx). + With("retry_count", executionCount). + With(ErrData(respErr)...) + } + + return resp, nil } func (middleware RetryHandler) isRetriableErrorCode(req *http.Request, code int) bool { diff --git a/src/internal/connector/graph/service.go b/src/internal/connector/graph/service.go index 01e6f4a73..275e76378 100644 --- a/src/internal/connector/graph/service.go +++ b/src/internal/connector/graph/service.go @@ -336,7 +336,7 @@ func (middleware RetryHandler) Intercept( response, err := pipeline.Next(req, middlewareIndex) if err != nil && !IsErrTimeout(err) { - return nil, clues.Stack(err).WithClues(ctx).With(ErrData(err)...) + return response, clues.Stack(err).WithClues(ctx).With(ErrData(err)...) } exponentialBackOff := backoff.NewExponentialBackOff()