{"record":{"id":"7ab52836fb671616","repo":"crewAIInc/crewAI","slug":"databricks-authentication-credentials-are-required","errorCode":null,"errorMessage":"Databricks authentication credentials are required. Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables.","messagePattern":"Databricks authentication credentials are required\\. Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/databricks_query_tool/databricks_query_tool.py","lineNumber":151,"sourceCode":"            default_schema (Optional[str]): Default schema to use for queries.\n            default_warehouse_id (Optional[str]): Default SQL warehouse ID to use.\n            **kwargs: Additional keyword arguments passed to BaseTool.\n        \"\"\"\n        super().__init__(**kwargs)\n        self.default_catalog = default_catalog\n        self.default_schema = default_schema\n        self.default_warehouse_id = default_warehouse_id\n        self._validate_credentials()\n\n    def _validate_credentials(self) -> None:\n        \"\"\"Validate that Databricks credentials are available.\"\"\"\n        has_profile = \"DATABRICKS_CONFIG_PROFILE\" in os.environ\n        has_direct_auth = (\n            \"DATABRICKS_HOST\" in os.environ and \"DATABRICKS_TOKEN\" in os.environ\n        )\n\n        if not (has_profile or has_direct_auth):\n            raise ValueError(\n                \"Databricks authentication credentials are required. \"\n                \"Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables.\"\n            )\n\n    @property\n    def workspace_client(self) -> WorkspaceClient:\n        \"\"\"Get or create a Databricks WorkspaceClient instance.\"\"\"\n        if self._workspace_client is None:\n            try:\n                from databricks.sdk import WorkspaceClient\n\n                self._workspace_client = WorkspaceClient()\n            except ImportError as e:\n                raise ImportError(\n                    \"`databricks-sdk` package not found, please run `uv add databricks-sdk`\"\n                ) from e\n        return self._workspace_client\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/databricks_query_tool/databricks_query_tool.py#L133-L169","documentation":"DatabricksQueryTool._validate_credentials() runs during the tool's __init__ and requires either DATABRICKS_CONFIG_PROFILE in the environment, or both DATABRICKS_HOST and DATABRICKS_TOKEN together. If neither combination is present it raises this ValueError, because the underlying databricks.sdk WorkspaceClient (constructed with no arguments) would have no way to authenticate.","triggerScenarios":"Instantiating DatabricksQueryTool() with no Databricks auth env vars set; setting only DATABRICKS_HOST without DATABRICKS_TOKEN (or vice versa — both are required for direct auth); running in a fresh shell/container where 'databricks configure' profile env was never exported.","commonSituations":"Env vars defined in .env but not loaded; vars set in a local terminal but missing in Docker/CI/agent runtime; partial config where only host is exported; relying on ~/.databrickscfg profiles without naming one via DATABRICKS_CONFIG_PROFILE.","solutions":["For token auth, export both variables: export DATABRICKS_HOST=https://<workspace-url> and export DATABRICKS_TOKEN=<personal access token>.","For profile auth, export DATABRICKS_CONFIG_PROFILE=<profile name matching ~/.databrickscfg>.","Add the variables to .env / CI secrets and verify with: python -c \"import os; print(all(k in os.environ for k in ('DATABRICKS_HOST','DATABRICKS_TOKEN')))\".","Remember DATABRICKS_HOST alone or DATABRICKS_TOKEN alone is insufficient — the pair must both be set."],"exampleFix":"# before\n# (no env vars set)\ntool = DatabricksQueryTool()  # ValueError at construction\n\n# after\n# shell:\n#   export DATABRICKS_HOST=https://dbc-123.cloud.databricks.com\n#   export DATABRICKS_TOKEN=dapiXXXXXXXX\ntool = DatabricksQueryTool()","handlingStrategy":"validation","validationCode":"import os\n\ndef databricks_auth_configured() -> bool:\n    return \"DATABRICKS_CONFIG_PROFILE\" in os.environ or (\n        \"DATABRICKS_HOST\" in os.environ and \"DATABRICKS_TOKEN\" in os.environ\n    )\n\nif not databricks_auth_configured():\n    raise SystemExit(\"Set DATABRICKS_CONFIG_PROFILE or DATABRICKS_HOST+DATABRICKS_TOKEN\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = DatabricksQueryTool()\nexcept ValueError as e:\n    if \"Databricks authentication credentials\" in str(e):\n        # load env / prompt operator, then retry construction\n        load_databricks_env()\n        tool = DatabricksQueryTool()\n    else:\n        raise","preventionTips":["Run a preflight env check for Databricks variables at app startup.","Inject credentials via CI/Docker secrets, not hard-coded defaults.","Remember HOST+TOKEN must appear together — a single one fails validation."],"tags":["databricks","environment-variable","authentication","configuration","init"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}