cube-js/cube · critical
CUBESQL_CUBE_URL is a required ENV variable
Error message
CUBESQL_CUBE_URL is a required ENV variable
What it means
The HTTP-based authentication service reads CUBESQL_CUBE_URL for the base URL of the Cube REST API when constructing an HttpAuthContext. If it is unset the process panics, since CubeSQL must know where to forward authentication/load requests.
Source
Thrown at rust/cubesql/cubesql/src/sql/auth_service.rs:83
crate::di_service!(SqlAuthDefaultImpl, [SqlAuthService]);
#[async_trait]
impl SqlAuthService for SqlAuthDefaultImpl {
async fn authenticate(
&self,
_request: SqlAuthServiceAuthenticateRequest,
_user: Option<String>,
password: Option<String>,
) -> Result<AuthenticateResponse, CubeError> {
Ok(AuthenticateResponse {
context: Arc::new(HttpAuthContext {
access_token: env::var("CUBESQL_CUBE_TOKEN")
.ok()
.unwrap_or_else(|| panic!("CUBESQL_CUBE_TOKEN is a required ENV variable")),
base_path: env::var("CUBESQL_CUBE_URL")
.ok()
.unwrap_or_else(|| panic!("CUBESQL_CUBE_URL is a required ENV variable")),
}),
password,
skip_password_check: false,
})
}
}
View on GitHub (pinned to 7d981676b3)
Solutions
- Set CUBESQL_CUBE_URL to the reachable Cube REST API base URL (e.g. http://cube:4000) and restart
- Add the env entry to your deployment manifest or .env file
- Verify network reachability of the URL from the CubeSQL container
Example fix
// before CUBESQL_CUBE_TOKEN=tok # CUBESQL_CUBE_URL unset // after CUBESQL_CUBE_TOKEN=tok CUBESQL_CUBE_URL=http://cube:4000
Defensive patterns
Strategy: validation
Validate before calling
fn require_env(key: &str) -> Result<String, String> {
match std::env::var(key) {
Ok(v) if !v.is_empty() => Ok(v),
_ => Err(format!("{} is required", key)),
}
}
let url = require_env("CUBESQL_CUBE_URL")?;
assert!(url.starts_with("http"), "CUBESQL_CUBE_URL must be a valid base URL"); Prevention
- Set CUBESQL_CUBE_URL alongside CUBESQL_CUBE_TOKEN in every environment
- Use service DNS names valid inside the deployment network
- Smoke-test the URL with curl from inside the container at startup
When it happens
Trigger: Starting CubeSQL with the HTTP auth service without CUBESQL_CUBE_URL defined in the environment.
Common situations: Service DNS name omitted in Kubernetes; misconfigured docker-compose service env; the Cube container address changed and the env var was dropped.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- CUBESQL_CUBE_TOKEN is a required ENV variable
- wrong configuration for environment variable '{}' with '{}'
- wrong configuration for environment variable '{}' with '{}'
- This query doesnt have a plan, because it already has values
- Should be rewritten with UtcTimestamp function
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/a1cc46649b8c468b.
Report an issue: GitHub.