snowflakedb / snowflake-connector-python

Snowflake Connector for Python
https://pypi.python.org/pypi/snowflake-connector-python/
Apache License 2.0
568 stars 456 forks source link

SNOW-1371225: Connector errors out when no config is present #1943

Closed der-eismann closed 1 month ago

der-eismann commented 2 months ago

Python version

3.9.18

Operating system and processor architecture

Linux-6.1.77-flatcar-aarch64-with-glibc2.34

Installed packages

asn1crypto==1.5.1
astroid==3.1.0
boto3==1.34.99
botocore==1.34.100
cachetools==5.3.3
certifi==2024.2.2
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
cryptography==42.0.7
dill==0.3.8
filelock==3.14.0
google-api-core==2.19.0
google-api-python-client==2.127.0
google-auth==2.29.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.0
googleapis-common-protos==1.63.0
httplib2==0.22.0
idna==3.7
isort==5.13.2
jmespath==1.0.1
mccabe==0.7.0
oauthlib==3.2.2
packaging==24.0
platformdirs==4.2.1
proto-plus==1.23.0
protobuf==4.25.3
psycopg2-binary==2.9.9
pyasn1==0.6.0
pyasn1_modules==0.4.0
pycparser==2.22
PyJWT==2.8.0
pylint==3.1.0
pynag==1.1.2
pyOpenSSL==24.1.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
requests==2.31.0
requests-oauthlib==2.0.0
rsa==4.9
s3transfer==0.10.1
six==1.16.0
snowflake-connector-python==3.10.0
sortedcontainers==2.4.0
tomli==2.0.1
tomlkit==0.12.4
typing_extensions==4.11.0
uritemplate==4.1.1
urllib3==1.26.18

What did you do?

We use the snowflake connector to run checks via Nagios. It worked fine with v3.8.1 so far, however after upgrading to 3.10.0 we started to see the following error:

(No output on stdout) stderr: Traceback (most recent call last):
File "/usr/lib64/nagios/plugins/check/check.py", line 15, in <module>
ctx = snowflake.connector.connect(
File "/opt/venv/lib64/python3.9/site-packages/snowflake/connector/__init__.py", line 55, in Connect
return SnowflakeConnection(**kwargs)
File "/opt/venv/lib64/python3.9/site-packages/snowflake/connector/connection.py", line 388, in __init__
easy_logging = EasyLoggingConfigPython()
File "/opt/venv/lib64/python3.9/site-packages/snowflake/connector/log_configuration.py", line 24, in __init__
self.parse_config_file()
File "/opt/venv/lib64/python3.9/site-packages/snowflake/connector/log_configuration.py", line 27, in parse_config_file
CONFIG_MANAGER.read_config()
File "/opt/venv/lib64/python3.9/site-packages/snowflake/connector/config_manager.py", line 323, in read_config
if not filep.exists():
File "/usr/lib64/python3.9/pathlib.py", line 1424, in exists
self.stat()
File "/usr/lib64/python3.9/pathlib.py", line 1232, in stat
return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied: '/root/.config/snowflake/config.toml'

The code at this location looks like this:

config = configparser.ConfigParser()
config.read(os.getenv('SNOWFLAKE_CONFIG'))

ctx = snowflake.connector.connect(
    user=config['snowflake']['username'],
    password=config['snowflake']['password'],
    account='vp12345.eu-west-1'
)

What did you expect to see?

I'd like to see the connector continue working as it was before. It's not mentioned anywhere that the config file is mandatory and it would be great if that error could be catched gracefully.

Can you set logging to DEBUG and collect the logs?

No response

sfc-gh-sghosh commented 1 month ago

Hello @der-eismann ,

Thanks for raising the issue; we are checking and will update you.

Regards, Sujan

sfc-gh-sghosh commented 1 month ago

Hello @der-eismann ,

You meant that before python connector 3.10.0, there was no need for a config file, and it was connecting fine, but now, with Python Connector 3.10.0, it's asking for a config file? If yes, could you please capture the Python log with connector 3.8.1 and let us know?

Regards, Sujan

sfc-gh-sghosh commented 1 month ago

Hello @der-eismann ,

I wanted to check if you had a chance to go through the previous post; if yes, please send us logs and repro or let us know if it's resolved.

Regards, Sujan

sfc-gh-sghosh commented 1 month ago

Hello @der-eismann ,

Since there is no reply from you, I am closing the ticket as of now; feel free to open it when you have the artifacts.

Regards, Sujan

sfc-gh-dszmolka commented 1 month ago

should be fixed by https://github.com/snowflakedb/snowflake-connector-python/pull/1965