{"record":{"id":"a1cc46649b8c468b","repo":"cube-js/cube","slug":"cubesql-cube-url-is-a-required-env-variable","errorCode":null,"errorMessage":"CUBESQL_CUBE_URL is a required ENV variable","messagePattern":"CUBESQL_CUBE_URL is a required ENV variable","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/cubesql/cubesql/src/sql/auth_service.rs","lineNumber":83,"sourceCode":"\ncrate::di_service!(SqlAuthDefaultImpl, [SqlAuthService]);\n\n#[async_trait]\nimpl SqlAuthService for SqlAuthDefaultImpl {\n    async fn authenticate(\n        &self,\n        _request: SqlAuthServiceAuthenticateRequest,\n        _user: Option<String>,\n        password: Option<String>,\n    ) -> Result<AuthenticateResponse, CubeError> {\n        Ok(AuthenticateResponse {\n            context: Arc::new(HttpAuthContext {\n                access_token: env::var(\"CUBESQL_CUBE_TOKEN\")\n                    .ok()\n                    .unwrap_or_else(|| panic!(\"CUBESQL_CUBE_TOKEN is a required ENV variable\")),\n                base_path: env::var(\"CUBESQL_CUBE_URL\")\n                    .ok()\n                    .unwrap_or_else(|| panic!(\"CUBESQL_CUBE_URL is a required ENV variable\")),\n            }),\n            password,\n            skip_password_check: false,\n        })\n    }\n}\n","sourceCodeStart":65,"sourceCodeEnd":90,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubesql/cubesql/src/sql/auth_service.rs#L65-L90","documentation":"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.","triggerScenarios":"Starting CubeSQL with the HTTP auth service without CUBESQL_CUBE_URL defined in the environment.","commonSituations":"Service DNS name omitted in Kubernetes; misconfigured docker-compose service env; the Cube container address changed and the env var was dropped.","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"],"exampleFix":"// before\nCUBESQL_CUBE_TOKEN=tok\n# CUBESQL_CUBE_URL unset\n// after\nCUBESQL_CUBE_TOKEN=tok\nCUBESQL_CUBE_URL=http://cube:4000","handlingStrategy":"validation","validationCode":"fn require_env(key: &str) -> Result<String, String> {\n    match std::env::var(key) {\n        Ok(v) if !v.is_empty() => Ok(v),\n        _ => Err(format!(\"{} is required\", key)),\n    }\n}\nlet url = require_env(\"CUBESQL_CUBE_URL\")?;\nassert!(url.starts_with(\"http\"), \"CUBESQL_CUBE_URL must be a valid base URL\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","env-var","auth","panic","startup"],"backgroundTag":"missing-env-var","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}