mlflow/mlflow · error · MlflowException
Failed to get credentials for DBFS; they are read from the D
Error message
Failed to get credentials for DBFS; they are read from the Databricks CLI credentials or MLFLOW_TRACKING* environment variables.
What it means
_get_host_creds_from_default_store retrieves credentials from the currently configured MLflow tracking store. If the active store is not a RestStore (e.g. a FileStore when tracking_uri is a local path), there is no way to obtain Databricks host credentials, so it raises MlflowException telling the user DBFS credentials must come from Databricks CLI config or MLFLOW_TRACKING* environment variables.
Source
Thrown at mlflow/store/artifact/dbfs_artifact_repo.py:191
return []
is_dir = dbfs_file["is_dir"]
artifact_size = None if is_dir else dbfs_file["file_size"]
infos.append(FileInfo(stripped_path, is_dir, artifact_size))
return sorted(infos, key=lambda f: f.path)
def _download_file(self, remote_file_path, local_path):
self._dbfs_download(
output_path=local_path, endpoint=self._get_dbfs_endpoint(remote_file_path)
)
def delete_artifacts(self, artifact_path=None):
raise MlflowException("Not implemented yet")
def _get_host_creds_from_default_store():
store = utils._get_store()
if not isinstance(store, RestStore):
raise MlflowException(
"Failed to get credentials for DBFS; they are read from the "
+ "Databricks CLI credentials or MLFLOW_TRACKING* environment "
+ "variables."
)
return store.get_host_creds
def dbfs_artifact_repo_factory(
artifact_uri: str, tracking_uri: str | None = None, registry_uri: str | None = None
):
"""
Returns an ArtifactRepository subclass for storing artifacts on DBFS.
This factory method is used with URIs of the form ``dbfs:/<path>``. DBFS-backed artifact
storage can only be used together with the RestStore.
In the special case where the URI is of the form
`dbfs:/databricks/mlflow-tracking/<Exp-ID>/<Run-ID>/<path>',View on GitHub (pinned to 6a27f2decc)
Solutions
- Set the Databricks profile in ~/.databrickscfg (via `databricks configure`) or export MLFLOW_TRACKING_URI=databricks (plus DATABRICKS_HOST/DATABRICKS_TOKEN) before constructing the DBFS artifact repo.
- Export MLFLOW_TRACKING_HOST and MLFLOW_TRACKING_TOKEN environment variables so HostCreds can be built without a RestStore.
- Ensure the active tracking store is a RestStore (a server/databricks URI), not a local file: path, when using dbfs://profile@databricks/ artifact URIs.
Example fix
// before
mlflow.set_tracking_uri("./mlruns") # FileStore
repo = get_artifact_repository("dbfs://profile@databricks/mnt/data") # raises
// after
os.environ["MLFLOW_TRACKING_HOST"] = "https://adb-xxx.azuredatabricks.net"
os.environ["MLFLOW_TRACKING_TOKEN"] = "dapi..."
# or: mlflow.set_tracking_uri("databricks") Defensive patterns
Strategy: validation
Validate before calling
import os
assert (os.environ.get("MLFLOW_TRACKING_HOST") and os.environ.get("MLFLOW_TRACKING_TOKEN")) or os.environ.get("MLFLOW_TRACKING_URI") == "databricks" or os.path.exists(os.path.expanduser("~/.databrickscfg")), "Configure Databricks credentials before using dbfs artifact repos" Type guard
def has_dbfs_credentials() -> bool:
import os
return bool(os.environ.get("MLFLOW_TRACKING_HOST") and os.environ.get("MLFLOW_TRACKING_TOKEN")) or os.environ.get("MLFLOW_TRACKING_URI") == "databricks" Try / catch
try:
repo = get_artifact_repository(dbfs_uri)
except MlflowException as e:
if "Failed to get credentials for DBFS" in str(e):
os.environ["MLFLOW_TRACKING_HOST"] = host
os.environ["MLFLOW_TRACKING_TOKEN"] = token
repo = get_artifact_repository(dbfs_uri) Prevention
- Set MLFLOW_TRACKING_HOST/MLFLOW_TRACKING_TOKEN or run `databricks configure` once per environment.
- Avoid mixing a local file-store tracking URI with dbfs://profile@databricks artifact URIs in the same process.
- In CI, provision Databricks secrets as env vars before MLflow imports.
When it happens
Trigger: Creating a DbfsArtifactRepo (dbfs://profile@databricks/...) or calling host-cred-dependent DBFS operations while mlflow.set_tracking_uri points to a local store (e.g. './mlruns' file store), so utils._get_store() returns a FileStore instead of a RestStore.
Common situations: Local scripts that set tracking_uri to a local directory but log artifacts to dbfs:// URIs; tests or notebooks mixing local tracking with Databricks artifact storage; missing Databricks CLI profile and missing MLFLOW_TRACKING_HOST/MLFLOW_TRACKING_TOKEN env vars.
Related errors
- No authentication configured within Databricks config file (
- Unable to load MLflow Host/Credentials from any provider in
- Unknown provider '{provider}'. Supported providers: {', '.jo
- Custom provider returned no DatabricksConfig: {_config_provi
- InvalidConfigurationError.for_profile(None)
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/028382cd92108c52.
Report an issue: GitHub.