Skip to content

Commit 1203a62

Browse files
committed
Incorporated the 401 status code error into the NonRecoverableNetworkError error handling
1 parent 98fc645 commit 1203a62

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# Icon must end with two \r
1212
Icon
1313

14+
# IntelliJ Files
15+
.idea
1416

1517
# Thumbnails
1618
._*

src/databricks/sql/auth/retry.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
MaxRetryDurationError,
2020
NonRecoverableNetworkError,
2121
OperationalError,
22-
AuthenticationFailureError,
2322
SessionAlreadyClosedError,
2423
UnsafeToRetryError,
2524
)
@@ -340,12 +339,8 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
340339
if status_code == 200:
341340
return False, "200 codes are not retried"
342341

343-
# Don't retry as there is an authentication error
344-
if status_code == 401:
345-
raise AuthenticationFailureError(
346-
"Received 401 - UNAUTHORIZED. Authentication is required and has failed or has not yet been provided."
347-
)
348-
if status_code == 403:
342+
# Invalid Credentials error. Don't retry
343+
if status_code == 403 or status_code == 401:
349344
raise NonRecoverableNetworkError(
350345
"Received 403 - FORBIDDEN. Confirm your authentication credentials."
351346
)

src/databricks/sql/exc.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ class NonRecoverableNetworkError(RequestError):
105105
"""Thrown if an HTTP code 501 is received"""
106106

107107

108-
class AuthenticationFailureError(RequestError):
109-
"""Thrown if an HTTP code 401 is received"""
110-
111-
112108
class UnsafeToRetryError(RequestError):
113109
"""Thrown if ExecuteStatement request receives a code other than 200, 429, or 503"""
114110

0 commit comments

Comments
 (0)