{"record":{"id":"ee85eb581b2b00cb","repo":"cube-js/cube","slug":"databricks-api-error-res-statustext","errorCode":null,"errorMessage":"Databricks API error: ${res.statusText}","messagePattern":"Databricks API error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-databricks-jdbc-driver/src/DatabricksDriver.ts","lineNumber":398,"sourceCode":"\n  public override async testConnection() {\n    let token: string;\n\n    // Databricks docs on accessing REST API\n    // https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m\n    if (this.config.properties.OAuth2Secret) {\n      const at = await this.getValidAccessToken();\n      token = `Bearer ${at}`;\n    } else {\n      token = `Bearer ${this.config.properties.PWD}`;\n    }\n\n    const res = await fetch(`https://${this.parsedConnectionProperties.host}/api/2.0/sql/warehouses/${this.parsedConnectionProperties.warehouseId}`, {\n      headers: { Authorization: token },\n    });\n\n    if (!res.ok) {\n      throw new Error(`Databricks API error: ${res.statusText}`);\n    }\n\n    const data = await res.json();\n\n    if (['DELETING', 'DELETED'].includes(data.state)) {\n      throw new Error(`Warehouse is being deleted (current state: ${data.state})`);\n    }\n\n    // There is also DEGRADED status, but it doesn't mean that cluster is 100% not working...\n    if (data.health?.status === 'FAILED') {\n      throw new Error(`Warehouse is unhealthy: ${data.health?.summary}. Details: ${data.health?.details}`);\n    }\n  }\n\n  public override async loadPreAggregationIntoTable(\n    preAggregationTableName: string,\n    loadSql: string,\n    params: unknown[],","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-databricks-jdbc-driver/src/DatabricksDriver.ts#L380-L416","documentation":"Thrown by testConnection when the Databricks REST call to describe the SQL warehouse (GET /api/2.0/sql/warehouses/{id}) returns a non-OK status. This API check runs before the JDBC connection test so configuration problems surface early. The statusText is included but not the response body or status code.","triggerScenarios":"testConnection fetches the warehouse info endpoint with an Authorization Bearer token; Databricks returns 401/403/404/429/5xx so res.ok is false.","commonSituations":"Wrong warehouseId parsed from the JDBC httpPath; token lacking CAN_USE/MANAGE permission on the warehouse; expired access token; transient 429 rate limiting or 503 from Databricks.","solutions":["Check that the JDBC URL httpPath points at a real SQL warehouse (/sql/1.0/warehouses/<id>) and the extracted warehouseId is correct","Verify the OAuth token/service principal has permission to query that warehouse","Retry if status was 429/503 (transient throttling), and check Databricks workspace status","Call the API manually with curl using the same token to see the full error body"],"exampleFix":"// before\nthrow new Error(`Databricks API error: ${res.statusText}`);\n// after\nif (!res.ok) {\n  const body = await res.text();\n  throw new Error(`Databricks API error: ${res.status} ${res.statusText}: ${body}`);\n}","handlingStrategy":"retry","validationCode":"const res = await fetch(`https://${host}/api/2.0/sql/warehouses/${warehouseId}`, { headers: { Authorization: `Bearer ${token}` } });\nif (!res.ok) console.error('Warehouse API check failed:', res.status, await res.text());","typeGuard":null,"tryCatchPattern":"try {\n  await driver.testConnection();\n} catch (e) {\n  if (String(e.message).startsWith('Databricks API error')) {\n    // inspect res.status cause (401/403/404/429), back off and retry for 429/5xx\n  }\n  throw e;\n}","preventionTips":["Verify warehouseId by calling the API with curl during setup","Ensure the service principal has CAN_USE on the warehouse","Implement backoff for 429/503 before surfacing errors"],"tags":["api","network","http","databricks"],"backgroundTag":"api-request-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}