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

feat(snowflake): better error message on key pair authentication #7734

Merged
merged 5 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def authenticator_type_is_valid(cls, v, values, field):
f"unsupported authenticator type '{v}' was provided,"
f" use one of {list(VALID_AUTH_TYPES.keys())}"
)
if (
values.get("private_key") is not None
or values.get("private_key_path") is not None
) and v != "KEY_PAIR_AUTHENTICATOR":
raise ValueError(
f"Either `private_key` and `private_key_path` is set but `authentication_type` is {v}. "
f"Should be set to 'KEY_PAIR_AUTHENTICATOR' when using key pair authentication"
)
if v == "KEY_PAIR_AUTHENTICATOR":
# If we are using key pair auth, we need the private key path and password to be set
if (
Expand Down
10 changes: 10 additions & 0 deletions metadata-ingestion/tests/unit/test_snowflake_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ def test_snowflake_config_with_no_connect_args_returns_base_connect_args():
}


def test_private_key_set_but_auth_not_changed():
with pytest.raises(ValidationError):
SnowflakeV2Config.parse_obj(
{
"account_id": "acctname",
"private_key_path": "/a/random/path",
}
)


def test_snowflake_config_with_connect_args_overrides_base_connect_args():
config: SnowflakeV2Config = SnowflakeV2Config.parse_obj(
{
Expand Down