Closed rschack-cedar closed 2 months ago
hi - this looks like a duplicate of https://github.com/snowflakedb/snowflake-connector-python/issues/1637 , a feature request to support externalbrowser
authentication in a headless environment, so closing this one as a duplicate
if you think your issue is entirely different, do comment please and i can reopen and look further.
@sfc-gh-dszmolka I'm not sure if it's the same issue, but it doesn't appear to be. I'm able to connect to Snowflake using externalbrowser
in a Docker container, but only if I'm running in an interactive python shell. When we run the .py
script from the CLI in the Docker container, then it fails. I'm always able to open the authenication URL and copy+paste the redirect URL. The failures only happen after that.
Oddly, if I include a pdb.set_trace()
in the script, it suddenly works.
The pdb.set_trace()
is indeed odd. Also reopening the issue so it could be investigated separately from the other one. Thank you for the inputs!
started looking at the issue and noticed the following:
2024-04-10 13:12:46,091 - MainThread _auth.py:211 - authenticate() - DEBUG - account={os, user=rschack, database=cedar, schema=sandbox, warehouse=compute_wh
observe account={os
which does not seem very correct, however looks to have a similar pattern as in the connection config:
c = snowflake.connector.connect(
account=f"{{os.getenv('SF_ACCOUNT_ID')}}.us-east-1.privatelink",
almost as the connector would believe that up to the first dot (which is usually the region separator like xy12345.us-east-1
) {os
is the account part.
Obviously, our situation is different in a way that I don't have a reverse proxy in front of my Snowflake account but when I run the script in a container in a non-interactive manner:
import snowflake.connector
import os
c = snowflake.connector.connect(
account=os.getenv("SFACCOUNT")
#host="snowflake.cedarinternal.com",
#port=443,
authenticator="externalbrowser",
user=os.getenv("SFUSER")
)
cur = c.cursor()
cur.execute("select 1 as id")
for col1 in cur:
print(col1)
it threw the Okta URL, which when manually copied into a browser then the response back into the prompt opened by the PythonConnector, allows to authenticate and run the select.
Would you be able to test a couple of things and see if they help?
this would be the quickest probably; instead account=f"{{os.getenv('SF_ACCOUNT_ID')}}.us-east-1.privatelink",
trying something like account=os.getenv('SF_ACCOUNT_ID') + '.us-east-1.privatelink'
or some other method which would make sure no templating elements can accidentally get into the account definition ?
if it doesn't help; then trying to use the Snowflake account directly instead of the proxy address (snowflake.cedarinternal.com
) ? Asking because the error message Remote end closed connection without response
does not come from Snowflake, if the connection is happening to the proxy instead:
2024-04-10 13:12:35,820 - MainThread connection.py:911 - __open_connection() - DEBUG - REST API object was created: snowflake.cedarinternal.com:443
Can you please check sometimes when you get a chance ?
@sfc-gh-dszmolka Thanks for looking into this. I hardcoded the account ID in the format of account="<account_id>.us-east-1.privatelink
(where <account_id>
is the actual ID value) and it made no difference. Here's that same log message now:
2024-04-23 19:42:08,643 - MainThread _auth.py:211 - authenticate() - DEBUG - account=<account_id>, user=rschack, database=cedar, schema=sandbox, warehouse=compute_wh, role=cedar_read_only, request_id=6faf81bf-6f31-46ed-a29c-0c19d6caaefd
When I remove the host
and port
options, I get the following error:
snowflake.connector.errors.DatabaseError: 250001 (08001): None: Failed to connect to DB: <account_id>.us-east-1.privatelink.snowflakecomputing.com:443. SAML response is invalid or matching user is not found. Contact your local system administrator and provide the error code - . The administrator can obtain troubleshooting information at https://docs.snowflake.com/en/user-guide/errors-saml#saml-error-codes.
In case it's helpful, here's a log file when I'm able to successfully connect in the python shell
2024-04-23 19:46:48,570 - MainThread connection.py:395 - __init__() - INFO - Snowflake Connector for Python Version: 3.8.0, Python Version: 3.11.6, Platform: Linux-6.6.12-linuxkit-aarch64-with-glibc2.31
2024-04-23 19:46:48,571 - MainThread connection.py:701 - connect() - DEBUG - connect
2024-04-23 19:46:48,572 - MainThread connection.py:1084 - __config() - DEBUG - __config
2024-04-23 19:46:48,572 - MainThread connection.py:1235 - __config() - INFO - This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.
2024-04-23 19:46:48,572 - MainThread converter.py:159 - __init__() - DEBUG - use_numpy: False
2024-04-23 19:46:48,573 - MainThread connection.py:911 - __open_connection() - DEBUG - REST API object was created: snowflake.cedarinternal.com:443
2024-04-23 19:46:48,573 - MainThread webbrowser.py:117 - prepare() - DEBUG - authenticating by Web Browser
2024-04-23 19:46:48,574 - MainThread webbrowser.py:150 - prepare() - DEBUG - step 1: query GS to obtain SSO url
2024-04-23 19:46:48,575 - MainThread webbrowser.py:471 - _get_sso_url() - DEBUG - account={os, authenticator=EXTERNALBROWSER, user=rschack
2024-04-23 19:46:48,576 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2024-04-23 19:46:48,576 - MainThread retry.py:351 - from_int() - DEBUG - Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2024-04-23 19:46:48,576 - MainThread network.py:1224 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 1/1 active sessions
2024-04-23 19:46:48,576 - MainThread network.py:875 - _request_exec_wrapper() - DEBUG - remaining request timeout: N/A ms, retry cnt: 1
2024-04-23 19:46:48,577 - MainThread network.py:1065 - _request_exec() - DEBUG - socket timeout: 60
2024-04-23 19:46:48,579 - MainThread connectionpool.py:1019 - _new_conn() - DEBUG - Starting new HTTPS connection (1): snowflake.cedarinternal.com:443
2024-04-23 19:46:48,773 - MainThread ssl_wrap_socket.py:79 - ssl_wrap_socket_with_ocsp() - DEBUG - OCSP Mode: FAIL_OPEN, OCSP response cache file name: None
2024-04-23 19:46:48,811 - MainThread ocsp_snowflake.py:492 - reset_cache_dir() - DEBUG - cache directory: /root/.cache/snowflake
2024-04-23 19:46:48,812 - MainThread ocsp_snowflake.py:530 - reset_ocsp_response_cache_uri() - DEBUG - ocsp_response_cache_uri: file:///root/.cache/snowflake/ocsp_response_cache.json
2024-04-23 19:46:48,812 - MainThread ocsp_snowflake.py:533 - reset_ocsp_response_cache_uri() - DEBUG - OCSP_VALIDATION_CACHE size: 209
2024-04-23 19:46:48,812 - MainThread ocsp_snowflake.py:332 - reset_ocsp_dynamic_cache_server_url() - DEBUG - OCSP response cache server is enabled: http://ocsp.snowflakecomputing.com/ocsp_response_cache.json
2024-04-23 19:46:48,812 - MainThread ocsp_snowflake.py:345 - reset_ocsp_dynamic_cache_server_url() - DEBUG - OCSP dynamic cache server RETRY URL: None
2024-04-23 19:46:48,812 - MainThread ocsp_snowflake.py:966 - validate() - DEBUG - validating certificate: snowflake.cedarinternal.com
2024-04-23 19:46:48,813 - MainThread ocsp_snowflake.py:972 - validate() - DEBUG - skipping OCSP check: snowflake.cedarinternal.com
2024-04-23 19:46:48,921 - MainThread connectionpool.py:474 - _make_request() - DEBUG - https://snowflake.cedarinternal.com:443 "POST /session/authenticator-request HTTP/1.1" 200 898
2024-04-23 19:46:48,922 - MainThread network.py:1092 - _request_exec() - DEBUG - SUCCESS
2024-04-23 19:46:48,923 - MainThread network.py:1229 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 0/1 active sessions
2024-04-23 19:46:48,923 - MainThread network.py:745 - _post_request() - DEBUG - ret[code] = None, after post request
2024-04-23 19:46:48,923 - MainThread webbrowser.py:158 - prepare() - DEBUG - Validate SSO URL
2024-04-23 19:46:48,924 - MainThread webbrowser.py:176 - prepare() - DEBUG - step 2: open a browser
2024-04-23 19:46:55,877 - MainThread _auth.py:174 - authenticate() - DEBUG - authenticate
2024-04-23 19:46:55,878 - MainThread _auth.py:208 - authenticate() - DEBUG - assertion content: 7V1pc6O8lv6eX5HKWzVfUmkDZp83uYMNxhs23pcvLgwCg9mM2OxfP8KOkzid7vsud6auZrqqKx208ejo6Og5R0L5/R9l4N/nIIFuFD4/kN+Ih3sQmpHlhs7zw2zaeuIf/vHyOzQCn4rFMYBxFEJwLwOYuqGRnivt0jSGYq0WJ25upMB3w/03GEaF7Rt78M0ElpG4YQqS0PC/mVFQs4FV8yPHDR/uO/Lzg2tRtEBzhMALFMeyAkMK6BeCJGgKFQiv75xGzw/x3rW2ug776pBrwKkwI49rI9Ubg2xWVw69aGHY2S4wtHnIwJ4pmag+hBnohDA1wvT5gSIo+omgn6j6lBREmhUZ8hvPMeuH+/lVAlQlASSTEIqXTj8/ZEkoRgZ0oRgaAYBiaooTSeuLqKgYJ1EamZF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uwMm4rJLbc9Ut+gpkGnb9ltCJMYicf1kwsAFfRNVtUlYE+1DeyMsdoAcJ8SxmTcyDwCFMQXEKZOOC9pa1VgAcT1NWv8ev1BEZo+EjuOCDHbEW8EbMFLhcoYqLYX36UitFZ2u+/ysYCNtKZwEhSuAMgvehN7oLiCaPbQ1C+uY9ygFG4XiQZG5etEPN9g/KiH+fFcoPZHTNfHkLBKh6Ll1V5lTdP0sg3ZkiWIutYWfMbnoUJmX3Xco7lKfSD4QkBJ6lj9nXyx+OQmCG/UW8IwjTBxI6/f5CPB94rq2UJghY4ps6TPGbrzg8itXj24fZrQ6xihVWo9oOZOQcOn7aXex3wO4UlwjjahzhgjT7c1YMD3kq2O2TWt2hdwgRv5QuliYGFOlzP4WOCFWlCdVgdO4KCqNXJjXGA+sku4wD57MGLGAKveGvmV1e5GwEWynH9OhMHrBheJvnhw0s8AN9cGIHINM1gFhZ5j9LzfJ1leJansfMFRPOYGD4+h6dSAFPRxoTNvcdE/sS5ks/J36d8uEz/mnW9Ef/9r+Nd/5rFy38D
2024-04-23 19:46:55,878 - MainThread _auth.py:211 - authenticate() - DEBUG - account={os, user=rschack, database=cedar, schema=sandbox, warehouse=compute_wh, role=cedar_read_only, request_id=b1150965-6a2b-429a-b397-842471474eac
2024-04-23 19:46:55,879 - MainThread _auth.py:244 - authenticate() - DEBUG - body['data']: {'CLIENT_APP_ID': 'PythonConnector', 'CLIENT_APP_VERSION': '3.8.0', 'SVN_REVISION': None, 'ACCOUNT_NAME': '{os', 'LOGIN_NAME': 'rschack', 'CLIENT_ENVIRONMENT': {'APPLICATION': 'PythonConnector', 'OS': 'Linux', 'OS_VERSION': 'Linux-6.6.12-linuxkit-aarch64-with-glibc2.31', 'PYTHON_VERSION': '3.11.6', 'PYTHON_RUNTIME': 'CPython', 'PYTHON_COMPILER': 'GCC 10.2.1 20210110', 'OCSP_MODE': 'FAIL_OPEN', 'TRACING': 10, 'LOGIN_TIMEOUT': None, 'NETWORK_TIMEOUT': None,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L5Fa2D7YsoWIGqNxFbUCLE=_-1_0', 'SESSION_PARAMETERS': {'CLIENT_PREFETCH_THREADS': 4, 'CLIENT_STORE_TEMPORARY_CREDENTIAL': False}}
2024-04-23 19:46:55,880 - MainThread network.py:1224 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 1/1 active sessions
2024-04-23 19:46:55,880 - MainThread network.py:875 - _request_exec_wrapper() - DEBUG - remaining request timeout: N/A ms, retry cnt: 1
2024-04-23 19:46:55,880 - MainThread network.py:1065 - _request_exec() - DEBUG - socket timeout: 60
2024-04-23 19:46:56,234 - MainThread connectionpool.py:474 - _make_request() - DEBUG - https://snowflake.cedarinternal.com:443 "POST /session/v1/login-request?request_id=b1150965-6a2b-429a-b397-842471474eac&databaseName=cedar&schemaName=sandbox&warehouse=compute_wh&roleName=cedar_read_only HTTP/1.1" 200 None
2024-04-23 19:46:56,236 - MainThread network.py:1092 - _request_exec() - DEBUG - SUCCESS
2024-04-23 19:46:56,237 - MainThread network.py:1229 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 0/1 active sessions
2024-04-23 19:46:56,237 - MainThread network.py:745 - _post_request() - DEBUG - ret[code] = None, after post request
2024-04-23 19:46:56,238 - MainThread _auth.py:371 - authenticate() - DEBUG - completed authentication
2024-04-23 19:46:56,238 - MainThread _auth.py:418 - authenticate() - DEBUG - token = ******
2024-04-23 19:46:56,239 - MainThread _auth.py:424 - authenticate() - DEBUG - master_token = ******
2024-04-23 19:46:56,239 - MainThread _auth.py:430 - authenticate() - DEBUG - id_token = NULL
2024-04-23 19:46:56,240 - MainThread _auth.py:436 - authenticate() - DEBUG - mfa_token = NULL
2024-04-23 19:46:58,533 - MainThread connection.py:830 - cursor() - DEBUG - cursor
2024-04-23 19:46:58,534 - MainThread cursor.py:910 - execute() - DEBUG - executing SQL/command
2024-04-23 19:46:58,534 - MainThread cursor.py:925 - execute() - DEBUG - query: [select 1 as id]
2024-04-23 19:46:58,534 - MainThread cursor.py:766 - _preprocess_pyformat_query() - DEBUG - binding: [select 1 as id] with input=[None], processed=[{}]
2024-04-23 19:46:58,535 - MainThread connection.py:1606 - _next_sequence_counter() - DEBUG - sequence counter: 1
2024-04-23 19:46:58,535 - MainThread cursor.py:640 - _execute_helper() - DEBUG - Request id: cff2fc3c-d595-413e-a1a2-7ea48ddb2cf9
2024-04-23 19:46:58,535 - MainThread cursor.py:642 - _execute_helper() - DEBUG - running query [select 1 as id]
2024-04-23 19:46:58,535 - MainThread cursor.py:649 - _execute_helper() - DEBUG - is_file_transfer: True
2024-04-23 19:46:58,536 - MainThread connection.py:1269 - cmd_query() - DEBUG - _cmd_query
2024-04-23 19:46:58,536 - MainThread _query_context_cache.py:155 - serialize_to_dict() - DEBUG - serialize_to_dict() called
2024-04-23 19:46:58,536 - MainThread connection.py:1296 - cmd_query() - DEBUG - sql=[select 1 as id], sequence_id=[1], is_file_transfer=[False]
2024-04-23 19:46:58,537 - MainThread network.py:1224 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 1/1 active sessions
2024-04-23 19:46:58,537 - MainThread network.py:875 - _request_exec_wrapper() - DEBUG - remaining request timeout: N/A ms, retry cnt: 1
2024-04-23 19:46:58,537 - MainThread network.py:1065 - _request_exec() - DEBUG - socket timeout: 60
2024-04-23 19:46:58,737 - MainThread connectionpool.py:474 - _make_request() - DEBUG - https://snowflake.cedarinternal.com:443 "POST /queries/v1/query-request?requestId=cff2fc3c-d595-413e-a1a2-7ea48ddb2cf9 HTTP/1.1" 200 None
2024-04-23 19:46:58,739 - MainThread network.py:1092 - _request_exec() - DEBUG - SUCCESS
2024-04-23 19:46:58,740 - MainThread network.py:1229 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 0/1 active sessions
2024-04-23 19:46:58,740 - MainThread network.py:745 - _post_request() - DEBUG - ret[code] = None, after post request
2024-04-23 19:46:58,740 - MainThread network.py:771 - _post_request() - DEBUG - Query id: 01b3de22-0409-85b1-0000-1ae935c79baa
2024-04-23 19:46:58,741 - MainThread _query_context_cache.py:189 - deserialize_json_dict() - DEBUG - deserialize_json_dict() called: data from server: {'entries': [{'id': 0, 'timestamp': 222767833098528, 'priority': 0}]}
2024-04-23 19:46:58,741 - MainThread _query_context_cache.py:230 - deserialize_json_dict() - DEBUG - deserialize {'id': 0, 'timestamp': 222767833098528, 'priority': 0}
2024-04-23 19:46:58,742 - MainThread _query_context_cache.py:101 - _sync_priority_map() - DEBUG - sync_priority_map called priority_map size = 0, new_priority_map size = 1
2024-04-23 19:46:58,742 - MainThread _query_context_cache.py:127 - trim_cache() - DEBUG - trim_cache() called. treeSet size is 1 and cache capacity is 5
2024-04-23 19:46:58,742 - MainThread _query_context_cache.py:136 - trim_cache() - DEBUG - trim_cache() returns. treeSet size is 1 and cache capacity is 5
2024-04-23 19:46:58,743 - MainThread _query_context_cache.py:269 - deserialize_json_dict() - DEBUG - deserialize_json_dict() returns
2024-04-23 19:46:58,743 - MainThread _query_context_cache.py:274 - log_cache_entries() - DEBUG - Cache Entry: (0, 222767833098528, 0)
2024-04-23 19:46:58,744 - MainThread cursor.py:983 - execute() - DEBUG - sfqid: 01b3de22-0409-85b1-0000-1ae935c79baa
2024-04-23 19:46:58,744 - MainThread cursor.py:989 - execute() - DEBUG - query execution done
2024-04-23 19:46:58,745 - MainThread cursor.py:1003 - execute() - DEBUG - SUCCESS
2024-04-23 19:46:58,745 - MainThread cursor.py:1022 - execute() - DEBUG - PUT OR GET: False
2024-04-23 19:46:58,746 - MainThread cursor.py:1135 - _init_result_and_meta() - DEBUG - Query result format: arrow
2024-04-23 19:46:58,746 - MainThread cursor.py:1149 - _init_result_and_meta() - INFO - Number of results in first chunk: 1
2024-04-23 19:47:00,538 - MainThread result_batch.py:68 - _create_nanoarrow_iterator() - DEBUG - Using nanoarrow as the arrow data converter
2024-04-23 19:47:00,538 - MainThread CArrowIterator.cpp:120 - CArrowIterator() - DEBUG - Arrow BatchSize: 1
2024-04-23 19:47:00,539 - MainThread CArrowChunkIterator.cpp:46 - CArrowChunkIterator() - DEBUG - Arrow chunk info: batchCount 1, columnCount 1, use_numpy: 0
2024-04-23 19:47:00,539 - MainThread nanoarrow_arrow_iterator.cpython-311-aarch64-linux-gnu.so:0 - __cinit__() - DEBUG - Batches read: 0
2024-04-23 19:47:00,540 - MainThread result_set.py:68 - result_set_iterator() - DEBUG - beginning to schedule result batch downloads
2024-04-23 19:47:00,540 - MainThread CArrowChunkIterator.cpp:70 - next() - DEBUG - Current batch index: 0, rows in current batch: 1
2024-04-23 19:47:02,414 - MainThread connection.py:758 - close() - INFO - closed
2024-04-23 19:47:02,414 - MainThread telemetry.py:211 - close() - DEBUG - Closing telemetry client.
2024-04-23 19:47:02,414 - MainThread connection.py:764 - close() - INFO - No async queries seem to be running, deleting session
2024-04-23 19:47:02,415 - MainThread network.py:1224 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 1/1 active sessions
2024-04-23 19:47:02,415 - MainThread network.py:875 - _request_exec_wrapper() - DEBUG - remaining request timeout: 5000 ms, retry cnt: 1
2024-04-23 19:47:02,415 - MainThread network.py:1065 - _request_exec() - DEBUG - socket timeout: 60
2024-04-23 19:47:02,529 - MainThread connectionpool.py:474 - _make_request() - DEBUG - https://snowflake.cedarinternal.com:443 "POST /session?delete=true HTTP/1.1" 200 None
2024-04-23 19:47:02,532 - MainThread network.py:1092 - _request_exec() - DEBUG - SUCCESS
2024-04-23 19:47:02,533 - MainThread network.py:1229 - _use_requests_session() - DEBUG - Session status for SessionPool 'snowflake.cedarinternal.com', SessionPool 0/1 active sessions
2024-04-23 19:47:02,534 - MainThread network.py:745 - _post_request() - DEBUG - ret[code] = None, after post request
2024-04-23 19:47:02,535 - MainThread _query_context_cache.py:141 - clear_cache() - DEBUG - clear_cache() called
2024-04-23 19:47:02,536 - MainThread connection.py:777 - close() - DEBUG - Session is closed
@rschack-cedar thank you for testing !
So getting the SAML assertion error means you actually got past the original error (http.client.RemoteDisconnected: Remote end closed connection without response
) when not going through your reverse proxy at snowflake.cedarinternal.com
, because now you could connect to Snowflake but since your SAML assertion is full of custom attributes which Snowflake does not necessary support (and to start with, the account
attribute is missing), you get a different error back.
(You can look into the assertion by copypasting the content into a tool like samltool.io)
But that means you now at least could connect to Snowflake (and the auth attempt was refused), contrary to the prior status of the connection being unexpectedly closed down by the proxy)
I would guess the SAML response is purposefully built in such a way for your company because you depend on the various attributes, this is not a problem.
How to proceed with this issue?
@sfc-gh-dszmolka Thanks David, I will investigate our reverse proxy (Cyral) in more detail. We were able to temporarily disable it, and I could connect to Snowflake (after removing the host
and port
params).
this is good news, thank you for letting me know ! Now the investigation can be focused at least. Speaking about which, if you don't need further help with this one, I recommend marking this issue as closed as it doesn't seem to be with the Snowflake Python Connector.
Python version
Python 3.11.6 (main, Nov 29 2023, 04:07:34) [GCC 10.2.1 20210110]
Operating system and processor architecture
Linux-6.6.12-linuxkit-aarch64-with-glibc2.31
Installed packages
What did you do?
While in a docker container, I'm unable to connect to Snowflake using
externalbrowser
(script below). Oddly, however, if I run the script interactively in a python shell, I can authenticate and connect to Snowflake without any issue. It's worth mentioning that we use a Cyral sidecar with SnowflakeThe
Dockerfile
anddocker-compose.yml
files:What did you expect to see?
When running in a script, the authentication fails with the following error:
snowflake.connector.errors.OperationalError: 250001: 250001: Could not connect to Snowflake backend after 2 attempt(s).Aborting
. When running the same program in an interactive python shell, it succeeds (output from interactive session below):Can you set logging to DEBUG and collect the logs?