{"record":{"id":"e1c913902ff42381","repo":"cube-js/cube","slug":"e-response-data-errormessage","errorCode":null,"errorMessage":"e.response.data.errorMessage","messagePattern":"e\\.response\\.data\\.errorMessage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-druid-driver/src/DruidClient.ts","lineNumber":92,"sourceCode":"\n          return {\n            columns,\n            rows\n          };\n        } else {\n          return {\n            columns: null,\n            rows: response.data,\n          };\n        }\n      } catch (e: any) {\n        if (cancelled) {\n          throw new Error('Query cancelled');\n        }\n\n        if (e.response && e.response.data) {\n          if (e.response.data.errorMessage) {\n            throw new Error(e.response.data.errorMessage);\n          }\n        }\n\n        throw e;\n      }\n    })();\n\n    promise.cancel = () => cancelObj.cancel();\n    return promise;\n  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":104,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-druid-driver/src/DruidClient.ts#L74-L104","documentation":"When the Druid HTTP request fails, DruidClient.query() inspects the axios error. If the response body contains errorMessage (Druid's structured SQL error field), that server-side message is thrown as the error, giving the real reason Druid rejected the query (syntax, missing datasource, permission, etc.).","triggerScenarios":"Any failed Druid SQL API call returning a non-2xx response whose body has data.errorMessage — e.g. SQL syntax errors, unknown datasource, authentication failures, query limit exceeded.","commonSituations":"Malformed generated SQL, querying a dropped datasource, Druid auth token expired, hitting Druid's maxConcurrency or query timeouts configured broker-side.","solutions":["Read the thrown errorMessage — it is Druid's own diagnostic; fix the SQL/datasource/permissions it names.","Validate SQL against Druid dialect (AVRO/JSON functions differ from ANSI); test the query in Druid's SQL console.","Check Druid broker logs and authentication credentials if the message is a permission/auth error."],"exampleFix":"// before\ndriver.query(\"SELECT * FROM missing_datasource\")\n// after\n// verify table exists first\nconst tables = await driver.getTablesQuery('druid');\nif (!tables.includes('my_table')) throw new Error('datasource not found');","handlingStrategy":"try-catch","validationCode":"// validate datasource name before querying\nconst tables = await driver.getTablesQuery('druid');\nif (!tables.map(t => t.TABLE_NAME).includes('my_datasource')) {\n  throw new Error('Druid datasource my_datasource does not exist');\n}","typeGuard":"function isDruidServerError(e) {\n  return e instanceof Error && typeof e.message === 'string' && e.message.length > 0 && !e.message.startsWith('Query cancelled');\n}","tryCatchPattern":"try {\n  await driver.query(sql, values);\n} catch (e) {\n  if (e.message === 'Query cancelled') return null;\n  // e.message here is Druid's data.errorMessage — surface it\n  logDruidError(e.message);\n  throw e;\n}","preventionTips":["Surface the raw message — it is Druid's own diagnostic","Test generated SQL in the Druid SQL console first","Validate datasources/permissions and Druid broker auth before deploying"],"tags":["druid","sql","server-error","http"],"backgroundTag":"sql-server-error","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}