Skip to content

Commit fb1f0e8

Browse files
committed
refactor: unify TOTP authentication error handling
1 parent a8c0e4b commit fb1f0e8

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

vertica_python/vertica/connection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,13 +1030,11 @@ def send_startup(totp_value=None):
10301030
short_msg = match.group(1).strip() if match else error_msg.strip()
10311031

10321032
if "Invalid TOTP" in short_msg:
1033-
print(f"Authentication failed: {INVALID_TOTP_MSG}")
10341033
self._logger.error(f"Authentication failed: {INVALID_TOTP_MSG}")
10351034
self.close_socket()
10361035
raise errors.ConnectionError(f"Authentication failed: {INVALID_TOTP_MSG}")
10371036

10381037
# Generic error fallback
1039-
print(f"Authentication failed: {short_msg}")
10401038
self._logger.error(short_msg)
10411039
raise errors.ConnectionError(f"Authentication failed: {short_msg}")
10421040
else:
@@ -1059,9 +1057,9 @@ def send_startup(totp_value=None):
10591057
# Validate using local precedence-based validator
10601058
result = validate_totp_code(totp_input, totp_is_valid=None)
10611059
if not result.ok:
1062-
msg = result.message or INVALID_TOTP_MSG
1063-
self._logger.error(msg)
1064-
raise errors.ConnectionError(msg)
1060+
msg = INVALID_TOTP_MSG
1061+
self._logger.error(f"Authentication failed: {msg}")
1062+
raise errors.ConnectionError(f"Authentication failed: {msg}")
10651063
totp_input = result.code
10661064
# ✅ Valid TOTP — retry connection
10671065
totp = totp_input

0 commit comments

Comments
 (0)