cube-js/cube · error · Error

e.response.data.errorMessage

Error message

e.response.data.errorMessage

What it means

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.).

Source

Thrown at packages/cubejs-druid-driver/src/DruidClient.ts:92

          return {
            columns,
            rows
          };
        } else {
          return {
            columns: null,
            rows: response.data,
          };
        }
      } catch (e: any) {
        if (cancelled) {
          throw new Error('Query cancelled');
        }

        if (e.response && e.response.data) {
          if (e.response.data.errorMessage) {
            throw new Error(e.response.data.errorMessage);
          }
        }

        throw e;
      }
    })();

    promise.cancel = () => cancelObj.cancel();
    return promise;
  }
}

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Read the thrown errorMessage — it is Druid's own diagnostic; fix the SQL/datasource/permissions it names.
  2. Validate SQL against Druid dialect (AVRO/JSON functions differ from ANSI); test the query in Druid's SQL console.
  3. Check Druid broker logs and authentication credentials if the message is a permission/auth error.

Example fix

// before
driver.query("SELECT * FROM missing_datasource")
// after
// verify table exists first
const tables = await driver.getTablesQuery('druid');
if (!tables.includes('my_table')) throw new Error('datasource not found');
Defensive patterns

Strategy: try-catch

Validate before calling

// validate datasource name before querying
const tables = await driver.getTablesQuery('druid');
if (!tables.map(t => t.TABLE_NAME).includes('my_datasource')) {
  throw new Error('Druid datasource my_datasource does not exist');
}

Type guard

function isDruidServerError(e) {
  return e instanceof Error && typeof e.message === 'string' && e.message.length > 0 && !e.message.startsWith('Query cancelled');
}

Try / catch

try {
  await driver.query(sql, values);
} catch (e) {
  if (e.message === 'Query cancelled') return null;
  // e.message here is Druid's data.errorMessage — surface it
  logDruidError(e.message);
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Malformed generated SQL, querying a dropped datasource, Druid auth token expired, hitting Druid's maxConcurrency or query timeouts configured broker-side.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/e1c913902ff42381. Report an issue: GitHub.