Skip to content

Commit ab8549f

Browse files
Narrow token retry to 429 and 503 only
Only retry token acquisition on HTTP 429 (rate limited) and 503 (service unavailable). Other 5xx errors are not retried to avoid masking persistent server-side failures. Co-authored-by: Isaac Signed-off-by: Ubuntu <renaud.hartert@databricks.com>
1 parent cf63f6c commit ab8549f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

config/experimental/auth/retrying_token_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type httpStatusCoder interface {
5555
// OAuth2 token endpoint errors, and transient network errors.
5656
func isRetriableTokenError(err error) bool {
5757
if code := httpStatusCode(err); code != 0 {
58-
return code == 429 || code >= 500
58+
return code == 429 || code == 503
5959
}
6060
var urlErr *url.Error
6161
if errors.As(err, &urlErr) {

config/experimental/auth/retrying_token_source_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ func TestRetryingTokenSource(t *testing.T) {
5151
wantCalls: 2,
5252
},
5353
{
54-
name: "retry on http 500 then succeed",
54+
name: "retry on http 503 then succeed",
5555
callErrors: []error{
56-
&testHTTPError{code: 500, message: "server error"},
56+
&testHTTPError{code: 503, message: "service unavailable"},
5757
nil,
5858
},
5959
wantToken: true,
@@ -143,7 +143,7 @@ func TestIsRetriableTokenError(t *testing.T) {
143143
{
144144
name: "http 500",
145145
err: &testHTTPError{code: 500},
146-
want: true,
146+
want: false,
147147
},
148148
{
149149
name: "http 503",
@@ -168,7 +168,7 @@ func TestIsRetriableTokenError(t *testing.T) {
168168
{
169169
name: "oauth2 retrieve error 500",
170170
err: &oauth2.RetrieveError{Response: &http.Response{StatusCode: 500}},
171-
want: true,
171+
want: false,
172172
},
173173
{
174174
name: "oauth2 retrieve error 400",

0 commit comments

Comments
 (0)