crewAIInc/crewAI · error · ValueError
Databricks authentication credentials are required. Set eith
Error message
Databricks authentication credentials are required. Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables.
What it means
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.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/databricks_query_tool/databricks_query_tool.py:151
default_schema (Optional[str]): Default schema to use for queries.
default_warehouse_id (Optional[str]): Default SQL warehouse ID to use.
**kwargs: Additional keyword arguments passed to BaseTool.
"""
super().__init__(**kwargs)
self.default_catalog = default_catalog
self.default_schema = default_schema
self.default_warehouse_id = default_warehouse_id
self._validate_credentials()
def _validate_credentials(self) -> None:
"""Validate that Databricks credentials are available."""
has_profile = "DATABRICKS_CONFIG_PROFILE" in os.environ
has_direct_auth = (
"DATABRICKS_HOST" in os.environ and "DATABRICKS_TOKEN" in os.environ
)
if not (has_profile or has_direct_auth):
raise ValueError(
"Databricks authentication credentials are required. "
"Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables."
)
@property
def workspace_client(self) -> WorkspaceClient:
"""Get or create a Databricks WorkspaceClient instance."""
if self._workspace_client is None:
try:
from databricks.sdk import WorkspaceClient
self._workspace_client = WorkspaceClient()
except ImportError as e:
raise ImportError(
"`databricks-sdk` package not found, please run `uv add databricks-sdk`"
) from e
return self._workspace_client
View on GitHub (pinned to 754d7323be)
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.
Example fix
# before # (no env vars set) tool = DatabricksQueryTool() # ValueError at construction # after # shell: # export DATABRICKS_HOST=https://dbc-123.cloud.databricks.com # export DATABRICKS_TOKEN=dapiXXXXXXXX tool = DatabricksQueryTool()
Defensive patterns
Strategy: validation
Validate before calling
import os
def databricks_auth_configured() -> bool:
return "DATABRICKS_CONFIG_PROFILE" in os.environ or (
"DATABRICKS_HOST" in os.environ and "DATABRICKS_TOKEN" in os.environ
)
if not databricks_auth_configured():
raise SystemExit("Set DATABRICKS_CONFIG_PROFILE or DATABRICKS_HOST+DATABRICKS_TOKEN") Try / catch
try:
tool = DatabricksQueryTool()
except ValueError as e:
if "Databricks authentication credentials" in str(e):
# load env / prompt operator, then retry construction
load_databricks_env()
tool = DatabricksQueryTool()
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- No platform integration token found, please set the CREWAI_P
- S3 bucket name not configured. Set CREWAI_BEDROCK_S3_BUCKET
- Zapier Actions API key is required
- API key must be provided either through constructor or MINDS
- APIFY_API_TOKEN environment variable is not set. Please set
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/7ab52836fb671616.
Report an issue: GitHub.