diff --git a/DESCRIPTION.md b/DESCRIPTION.md index 773f937a7..7c347f22c 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -11,6 +11,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne - v3.12.1(TBD) - Fixed a bug that session token is logged when renewing session. - Fixed a bug that disabling client telemetry does not work. + - Fixed a bug where `login_timeout` when passed as string raised `TypeError` during login retry step. - Use `pathlib` instead of `os` for default config file location resolution. - Removed upper `cryptogaphy` version pin. - Removed reference to script `snowflake-export-certs` (its backing module was already removed long ago) diff --git a/src/snowflake/connector/auth/_auth.py b/src/snowflake/connector/auth/_auth.py index be60a2ce5..b8aa8f485 100644 --- a/src/snowflake/connector/auth/_auth.py +++ b/src/snowflake/connector/auth/_auth.py @@ -198,7 +198,7 @@ def authenticate( self._rest._connection._internal_application_name, self._rest._connection._internal_application_version, self._rest._connection._ocsp_mode(), - self._rest._connection._login_timeout, + self._rest._connection.login_timeout, self._rest._connection._network_timeout, self._rest._connection._socket_timeout, ) diff --git a/src/snowflake/connector/auth/okta.py b/src/snowflake/connector/auth/okta.py index 0b8742781..28452e313 100644 --- a/src/snowflake/connector/auth/okta.py +++ b/src/snowflake/connector/auth/okta.py @@ -170,7 +170,7 @@ def _step1( conn._internal_application_name, conn._internal_application_version, conn._ocsp_mode(), - conn._login_timeout, + conn.login_timeout, conn._network_timeout, ) diff --git a/src/snowflake/connector/auth/webbrowser.py b/src/snowflake/connector/auth/webbrowser.py index 41f9f323c..b42fa9596 100644 --- a/src/snowflake/connector/auth/webbrowser.py +++ b/src/snowflake/connector/auth/webbrowser.py @@ -462,7 +462,7 @@ def _get_sso_url( conn._rest._connection._internal_application_name, conn._rest._connection._internal_application_version, conn._rest._connection._ocsp_mode(), - conn._rest._connection._login_timeout, + conn._rest._connection.login_timeout, conn._rest._connection._network_timeout, ) diff --git a/src/snowflake/connector/connection.py b/src/snowflake/connector/connection.py index 8b1c1f939..eb8f85304 100644 --- a/src/snowflake/connector/connection.py +++ b/src/snowflake/connector/connection.py @@ -1018,7 +1018,7 @@ def __open_connection(self): elif self._authenticator == DEFAULT_AUTHENTICATOR: self.auth_class = AuthByDefault( password=self._password, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) elif self._authenticator == EXTERNAL_BROWSER_AUTHENTICATOR: @@ -1038,7 +1038,7 @@ def __open_connection(self): protocol=self._protocol, host=self.host, port=self.port, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) else: @@ -1048,7 +1048,7 @@ def __open_connection(self): protocol=self._protocol, host=self.host, port=self.port, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) @@ -1063,13 +1063,13 @@ def __open_connection(self): self.auth_class = AuthByKeyPair( private_key=private_key, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) elif self._authenticator == OAUTH_AUTHENTICATOR: self.auth_class = AuthByOAuth( oauth_token=self._token, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) elif self._authenticator == USR_PWD_MFA_AUTHENTICATOR: @@ -1085,14 +1085,14 @@ def __open_connection(self): self.auth_class = AuthByUsrPwdMfa( password=self._password, mfa_token=self.rest.mfa_token, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) else: # okta URL, e.g., https://.okta.com/ self.auth_class = AuthByOkta( application=self.application, - timeout=self._login_timeout, + timeout=self.login_timeout, backoff_generator=self._backoff_generator, ) diff --git a/test/integ/test_connection.py b/test/integ/test_connection.py index d52a48c18..4891a6fc5 100644 --- a/test/integ/test_connection.py +++ b/test/integ/test_connection.py @@ -279,6 +279,25 @@ def test_bad_db(db_parameters): cnx.close() +def test_with_string_login_timeout(db_parameters): + """Test that login_timeout when passed as string does not raise TypeError. + + In this test, we pass bad login credentials to raise error and trigger login + timeout calculation. We expect to see DatabaseError instead of TypeError that + comes from str - int arithmetic. + """ + with pytest.raises(DatabaseError): + snowflake.connector.connect( + protocol="http", + user="bogus", + password="bogus", + host=db_parameters["host"], + port=db_parameters["port"], + account=db_parameters["account"], + login_timeout="5", + ) + + def test_bogus(db_parameters): """Attempts to login with invalid user name and password.