pola-rs/polars · error · ValueError
{credential_provider}
Error message
{credential_provider} What it means
`pl.Config.set_default_credential_provider(provider)` only accepts the string 'auto' (reset to automatic detection) or an actual credential provider object such as `pl.CredentialProviderAWS(...)`. Any other string raises ValueError whose message is just the offending string itself — an unusual pattern, so the traceback looks odd but simply means 'invalid credential provider name'.
Source
Thrown at py-polars/src/polars/config.py:1732
credential_provider
Provide a function that can be called to provide cloud storage
credentials. The function is expected to return a dictionary of
credential keys along with an optional credential expiry time.
Can also be set to None, which globally disables auto-initialization
of credential providers, or "auto" (the default behavior).
Examples
--------
>>> pl.Config.set_default_credential_provider(
... pl.CredentialProviderAWS(
... assume_role={"RoleArn": "...", "RoleSessionName": "..."}
... )
... )
<class 'polars.config.Config'>
"""
if isinstance(credential_provider, str) and credential_provider != "auto":
raise ValueError(credential_provider)
_set_default_credential_provider(credential_provider)
return cls
@classmethod
def reload_env_vars(cls) -> None:
"""
Update the Polars config from the set environment variables.
Normally you need not call this, it is only necessary when updating
undocumented (environment-variable-only) config flags from Python after
importing Polars.
"""
plr.config_reload_env_vars()
View on GitHub (pinned to 68506541d2)
Solutions
- Pass an instance: `pl.Config.set_default_credential_provider(pl.CredentialProviderAWS(assume_role={...}))`.
- Pass 'auto' to restore automatic credential resolution, or None to clear the override.
- Keep provider selection in Python code rather than serializing provider names to config files.
Example fix
# before
pl.Config.set_default_credential_provider("aws") # ValueError: aws
# after
pl.Config.set_default_credential_provider(
pl.CredentialProviderAWS(assume_role={"RoleArn": "...", "RoleSessionName": "..."})
) Defensive patterns
Strategy: validation
Validate before calling
def set_credential_provider(provider: object) -> None:
if isinstance(provider, str) and provider != "auto":
raise ValueError(
f"credential provider must be an instance or 'auto', got name {provider!r}; "
"e.g. pl.CredentialProviderAWS(...)"
)
pl.Config.set_default_credential_provider(provider) Type guard
def is_valid_credential_provider(provider: object) -> bool:
return not isinstance(provider, str) or provider == "auto" Prevention
- Never serialize credential provider names to config; construct provider objects in code.
- Remember the ValueError message is just the bad string itself — log the provider argument for context.
When it happens
Trigger: `pl.Config.set_default_credential_provider('aws')` or 'auto_detect' — passing a provider name where an object is required; loading provider choice from a config file as a string.
Common situations: Assuming providers are selectable by name string; migrating code that stored provider names; mixing up this global default with the per-call credential_provider argument of scan/read functions.
Related errors
- `separator` must be a single character; found {separator!r}
- number of characters must be > 0
- invalid alignment: {format!r}
- invalid table format name: {format!r} Expected one of: {', '
- limit should be positive
AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19).
Data as JSON: /api/errors/cfc22a6d9c2881f2.
Report an issue: GitHub.