Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1038042: Login timeout gets casted as string and not integer #1869

Open
carrasquel opened this issue Feb 1, 2024 · 2 comments
Open

Comments

@carrasquel
Copy link

carrasquel commented Feb 1, 2024

Python version

3.10.12

Operating system and processor architecture

Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.35

Installed packages

snowflake-sqlalchemy==1.5.1
snowflake-connector-python==3.6.0

What did you do?

When trying to connect to a host using a url like snowflake://user:password@host/DEMO_DB/database?role=&warehouse=&client_session_keep_alive=True&login_timeout=2

the login timeout gets casted as string and not properly coverted to integer.

One of our automated QA tests, uses a wrong host to catch the exception:
(snowflake.connector.errors.OperationalError) 250001: 250001: Could not connect to Snowflake backend after 1 attempt(s).Aborting

But instead is getting the following:
File "/home/envs/venv/lib/python3.8/site-packages/snowflake/connector/time_util.py", line 130, in remaining_time_millis
    return timeout_millis - elapsed_time_millis
TypeError: unsupported operand type(s) for -: 'str' and 'int'

So I located to cause of this issue is that in the module /snowflake/connector/connection.py for the class SnowflakeConnection, there is a property login_timeout, to convert _login_timeout to integer, but this property is never executed, the plain _login_timeout is used instead.

What did you expect to see?

This type error
TypeError: unsupported operand type(s) for -: 'str' and 'int'

when a non valid host is used

Can you set logging to DEBUG and collect the logs?

import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)
@github-actions github-actions bot changed the title Login timeout gets casted as string and not integer SNOW-1038042: Login timeout gets casted as string and not integer Feb 1, 2024
@sfc-gh-aling
Copy link
Collaborator

thanks for reaching out and catching the bug for us!
is it possible for you to help create a PR to fix the issue?

@carrasquel
Copy link
Author

Yes I can help, and will submit a PR to fis this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants