Skip to content

Commit

Permalink
Incorporated the 401 status code error into the NonRecoverableNetwork…
Browse files Browse the repository at this point in the history
…Error error handling
  • Loading branch information
jprakash-db committed Jun 17, 2024
1 parent 98fc645 commit 1203a62
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Icon must end with two \r
Icon

# IntelliJ Files
.idea

# Thumbnails
._*
Expand Down
9 changes: 2 additions & 7 deletions src/databricks/sql/auth/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
MaxRetryDurationError,
NonRecoverableNetworkError,
OperationalError,
AuthenticationFailureError,
SessionAlreadyClosedError,
UnsafeToRetryError,
)
Expand Down Expand Up @@ -340,12 +339,8 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
if status_code == 200:
return False, "200 codes are not retried"

# Don't retry as there is an authentication error
if status_code == 401:
raise AuthenticationFailureError(
"Received 401 - UNAUTHORIZED. Authentication is required and has failed or has not yet been provided."
)
if status_code == 403:
# Invalid Credentials error. Don't retry
if status_code == 403 or status_code == 401:
raise NonRecoverableNetworkError(
"Received 403 - FORBIDDEN. Confirm your authentication credentials."
)
Expand Down
4 changes: 0 additions & 4 deletions src/databricks/sql/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ class NonRecoverableNetworkError(RequestError):
"""Thrown if an HTTP code 501 is received"""


class AuthenticationFailureError(RequestError):
"""Thrown if an HTTP code 401 is received"""


class UnsafeToRetryError(RequestError):
"""Thrown if ExecuteStatement request receives a code other than 200, 429, or 503"""

Expand Down

0 comments on commit 1203a62

Please sign in to comment.