Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Providing no credentials to AzureBlobStorageCredentials raises wrong error message #140

Closed
serinamarie opened this issue Mar 14, 2024 · 0 comments · Fixed by #148
Closed
Labels
good first issue Good for newcomers

Comments

@serinamarie
Copy link
Contributor

serinamarie commented Mar 14, 2024

When I don't provide anything to my AzureBlobStorageCredentials:

e.g.

credentials = AzureBlobStorageCredentials()

I get this error:

❯ python qa.py
Traceback (most recent call last):
  File "/Users/bean/code-oss/prefect-azure/qa.py", line 6, in <module>
    credentials = AzureBlobStorageCredentials(
  File "/Users/bean/code-oss/prefect-azure/azurevenv/lib/python3.10/site-packages/prefect/blocks/core.py", line 265, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/bean/code-oss/prefect-azure/azurevenv/lib/python3.10/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for AzureBlobStorageCredentials
__root__
  Must provide either a connection string or account URL, but not both. (type=value_error)

Because the validator is only doing an xor check, not checking that one of the values is True.

@root_validator
def check_connection_string_or_account_url(
    cls, values: Dict[str, Any]
) -> Dict[str, Any]:
    """
    Checks that either a connection string or account URL is provided, not both.
    """
    has_account_url = values.get("account_url") is not None
    has_conn_str = values.get("connection_string") is not None
    if not bool(has_account_url ^ has_conn_str):
        raise ValueError(
            "Must provide either a connection string or account URL, but not both."
        )
    return values
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant