Skip to content

Commit 3d36b9a

Browse files
committed
Fix type checking and formatting issues in retry.py
1 parent f064e6e commit 3d36b9a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/databricks/sql/auth/retry.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CommandIdempotency(Enum):
6767
# These are client error codes that indicate permanent issues
6868
NON_RETRYABLE_STATUS_CODES = {
6969
400, # Bad Request
70-
401, # Unauthorized
70+
401, # Unauthorized
7171
403, # Forbidden
7272
404, # Not Found
7373
405, # Method Not Allowed
@@ -408,7 +408,9 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
408408
return False, "Only POST requests are retried"
409409

410410
# Get command idempotency for use in multiple conditions below
411-
command_idempotency = COMMAND_IDEMPOTENCY_MAP.get(self.command_type, CommandIdempotency.IDEMPOTENT)
411+
command_idempotency = COMMAND_IDEMPOTENCY_MAP.get(
412+
self.command_type or CommandType.OTHER, CommandIdempotency.IDEMPOTENT
413+
)
412414

413415
# Request failed, was a non-idempotent command and the command may have reached the server
414416
if (
@@ -418,7 +420,7 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
418420
):
419421
return (
420422
False,
421-
f"{self.command_type.value} command can only be retried for codes 429 and 503",
423+
f"{self.command_type.value if self.command_type else 'Unknown'} command can only be retried for codes 429 and 503",
422424
)
423425

424426
# Request failed with a dangerous code, was a non-idempotent command, but user forced retries for this

0 commit comments

Comments
 (0)