Skip to content

SNOW-3995071: Expand tilde in token_file_path - #3044

Open
cristiangirlea wants to merge 1 commit into
snowflakedb:mainfrom
cristiangirlea:SNOW-3995071-expand-tilde-token-file-path
Open

cristiangirlea wants to merge 1 commit into
snowflakedb:mainfrom
cristiangirlea:SNOW-3995071-expand-tilde-token-file-path

Conversation

@cristiangirlea

@cristiangirlea cristiangirlea commented Sep 30, 2026 •

Copy link
Copy Markdown

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-3995071: PAT to support path expansion #3006

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    token_file_path was passed straight to open(), so a path using the home shorthand, such as ~/.snowflake/pat.token in connections.toml, failed with FileNotFoundError. This PR reuses the existing util_text.expand_tilde helper, which SNOW-3020359 expand tilde to key file path in connection #2759 introduced for private_key_file, so both connection parameters behave the same way. Non-string values and environments where the home directory can't be resolved pass through unchanged, as with private_key_file.

    The async SnowflakeConnection inherits the same __config path, so it is covered too.

    Test: test_pat_token_file_path_expands_tilde points HOME/USERPROFILE at a temp directory, connects with PROGRAMMATIC_ACCESS_TOKEN and token_file_path="~/.snowflake/pat.token", and asserts that the token read from the file is the one sent in the login request. Without the fix it fails with the error reported in the issue: FileNotFoundError: [Errno 2] No such file or directory: '~/.snowflake/pat.token'.

    Also ran test_connection.py, test_auth_keypair.py, test_text_util.py and aio/test_connection_async_unit.py locally (152 passed), and pre-commit passes on the changed files.

@cristiangirlea
cristiangirlea force-pushed the SNOW-3995071-expand-tilde-token-file-path branch from 5c53e38 to f1b1e4e Compare September 30, 2026 16:41
`token_file_path` was passed straight to `open()`, so a path such as
`~/.snowflake/pat.token` (e.g. from connections.toml) failed with
FileNotFoundError. Reuse the existing `expand_tilde` helper, as already
done for `private_key_file`. The async connection shares the same
config path, so it is covered too.

Fixes snowflakedb#3006
@cristiangirlea
cristiangirlea force-pushed the SNOW-3995071-expand-tilde-token-file-path branch from f1b1e4e to c4557d8 Compare October 1, 2026 12:00
@cristiangirlea

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SNOW-3995071: PAT to support path expansion

1 participant