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

Dagster-Snowflake: private key not accepted unless base64-encoded #26276

Open
pengw0048 opened this issue Dec 4, 2024 · 0 comments · May be fixed by #26278
Open

Dagster-Snowflake: private key not accepted unless base64-encoded #26276

pengw0048 opened this issue Dec 4, 2024 · 0 comments · May be fixed by #26278
Labels
integration: snowflake Related to dagster-snowflake type: bug Something isn't working

Comments

@pengw0048
Copy link
Contributor

What's the issue?

If SnowflakeResource is initiated with a private_key string as found in a .p8 file, get_connection() will fail. This is because private_key as a str field is not correctly passed to the cryptography library function serialization.load_pem_private_key() here

p_key = serialization.load_pem_private_key(
private_key, backend=default_backend(), **kwargs
)

What did you expect to happen?

A connection is established if the credentials are valid.

How to reproduce?

import dagster_snowflake
pk="""-----BEGIN PRIVATE KEY-----
......
-----END PRIVATE KEY-----"""
ssr=dagster_snowflake.SnowflakeResource(account='XXX',user='YYY',private_key=pk)
with ssr.get_connection() as conn, conn.cursor() as cur:
  cur.execute('select 1')

gives:

Traceback (most recent call last):
  File ".../venv/lib/python3.10/site-packages/dagster_snowflake/resources.py", line 398, in _snowflake_private_key
    p_key = serialization.load_pem_private_key(
TypeError: argument 'data': from_buffer() cannot return the address of a unicode object

Dagster version

1.8.13

Deployment type

None

Deployment details

No response

Additional information

Changing the above lines of library to the below seems to help:

            p_key = serialization.load_pem_private_key(
                private_key.encode(), backend=default_backend(), **kwargs   # added ".encode()"
            )

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.
By submitting this issue, you agree to follow Dagster's Code of Conduct.

@pengw0048 pengw0048 added the type: bug Something isn't working label Dec 4, 2024
@garethbrickman garethbrickman added the integration: snowflake Related to dagster-snowflake label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: snowflake Related to dagster-snowflake type: bug Something isn't working
Projects
None yet
2 participants