{"record":{"id":"028382cd92108c52","repo":"mlflow/mlflow","slug":"failed-to-get-credentials-for-dbfs-they-are-read","errorCode":null,"errorMessage":"Failed to get credentials for DBFS; they are read from the Databricks CLI credentials or MLFLOW_TRACKING* environment variables.","messagePattern":"Failed to get credentials for DBFS; they are read from the Databricks CLI credentials or MLFLOW_TRACKING\\* environment variables\\.","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/store/artifact/dbfs_artifact_repo.py","lineNumber":191,"sourceCode":"                return []\n            is_dir = dbfs_file[\"is_dir\"]\n            artifact_size = None if is_dir else dbfs_file[\"file_size\"]\n            infos.append(FileInfo(stripped_path, is_dir, artifact_size))\n        return sorted(infos, key=lambda f: f.path)\n\n    def _download_file(self, remote_file_path, local_path):\n        self._dbfs_download(\n            output_path=local_path, endpoint=self._get_dbfs_endpoint(remote_file_path)\n        )\n\n    def delete_artifacts(self, artifact_path=None):\n        raise MlflowException(\"Not implemented yet\")\n\n\ndef _get_host_creds_from_default_store():\n    store = utils._get_store()\n    if not isinstance(store, RestStore):\n        raise MlflowException(\n            \"Failed to get credentials for DBFS; they are read from the \"\n            + \"Databricks CLI credentials or MLFLOW_TRACKING* environment \"\n            + \"variables.\"\n        )\n    return store.get_host_creds\n\n\ndef dbfs_artifact_repo_factory(\n    artifact_uri: str, tracking_uri: str | None = None, registry_uri: str | None = None\n):\n    \"\"\"\n    Returns an ArtifactRepository subclass for storing artifacts on DBFS.\n\n    This factory method is used with URIs of the form ``dbfs:/<path>``. DBFS-backed artifact\n    storage can only be used together with the RestStore.\n\n    In the special case where the URI is of the form\n    `dbfs:/databricks/mlflow-tracking/<Exp-ID>/<Run-ID>/<path>',","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/artifact/dbfs_artifact_repo.py#L173-L209","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmlflow.set_tracking_uri(\"./mlruns\")  # FileStore\nrepo = get_artifact_repository(\"dbfs://profile@databricks/mnt/data\")  # raises\n\n// after\nos.environ[\"MLFLOW_TRACKING_HOST\"] = \"https://adb-xxx.azuredatabricks.net\"\nos.environ[\"MLFLOW_TRACKING_TOKEN\"] = \"dapi...\"\n# or: mlflow.set_tracking_uri(\"databricks\")","handlingStrategy":"validation","validationCode":"import os\nassert (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\"","typeGuard":"def has_dbfs_credentials() -> bool:\n    import os\n    return bool(os.environ.get(\"MLFLOW_TRACKING_HOST\") and os.environ.get(\"MLFLOW_TRACKING_TOKEN\")) or os.environ.get(\"MLFLOW_TRACKING_URI\") == \"databricks\"","tryCatchPattern":"try:\n    repo = get_artifact_repository(dbfs_uri)\nexcept MlflowException as e:\n    if \"Failed to get credentials for DBFS\" in str(e):\n        os.environ[\"MLFLOW_TRACKING_HOST\"] = host\n        os.environ[\"MLFLOW_TRACKING_TOKEN\"] = token\n        repo = get_artifact_repository(dbfs_uri)","preventionTips":["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."],"tags":["databricks","dbfs","credentials","configuration","tracking-store"],"backgroundTag":"missing-credentials","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}