cube-js/cube · error
response.error
Error message
response.error
What it means
CubeSQL responses arrive as a newline-delimited payload with a JSON schema line first. If the first line is not valid JSON, the code concludes the entire `error` string is a plain-text server error and rethrows it verbatim.
Source
Thrown at packages/cubejs-client-core/src/index.ts:827
// Check if this is a timeout or abort error from transport
if (response.error === 'timeout') {
const timeoutMs = options?.timeout || 5 * 60 * 1000;
throw new Error(`CubeSQL query timed out after ${timeoutMs}ms`);
}
if (response.error === 'aborted') {
throw new Error('CubeSQL query was aborted');
}
const [schema, ...data] = response.error.split('\n');
let parsedSchema: any;
try {
parsedSchema = JSON.parse(schema);
} catch (err) {
// Schema line isn't valid JSON — the whole `error` payload is a real error.
throw new Error(response.error);
}
const rows: any[] = [];
for (const line of data) {
if (line.trim().length) {
let parsed: any;
try {
parsed = JSON.parse(line);
} catch (err) {
// A non-JSON line after a valid schema means a malformed payload — fall
// back to surfacing the raw response rather than dropping rows silently.
throw new Error(response.error);
}
// The stream can interleave an error chunk after the schema (e.g. a
// post-processing/cast error surfaced mid-result). Such a line has no
// `data`, so the previous `JSON.parse(d).data` concat pushed an `undefined`View on GitHub (pinned to 7d981676b3)
Solutions
- Read the thrown message — it contains the raw server error; fix the underlying SQL/server issue
- Verify you are hitting the cubesql endpoint of a Cube deployment that supports the SQL API
- Check for proxies returning HTML error pages instead of JSONL
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the deployment supports the SQL API and no proxy rewrites the endpoint
const health = await fetch(`${apiUrl.replace(/\/$/, '')}/load`, { headers: { authorization: token } });
if (!health.ok) throw new Error('Cube API endpoint unreachable; fix before cubeSql calls'); Try / catch
try { const res = await client.cubeSql(sql); } catch (e) {
// raw server error is rethrown verbatim — inspect and fix server/SQL issue
console.error('CubeSQL server error:', e.message);
} Prevention
- Validate SQL against the cube schema before sending
- Ensure proxies return JSONL, not HTML error pages
- Pin compatible Cube server and client versions
When it happens
Trigger: cubeSql() receiving an error payload whose first line isn't JSON — e.g. a raw stack trace, HTML error page, or plain message from the CubeSQL server.
Common situations: SQL syntax errors surfaced as plain text; server behind a proxy returning HTML 502 pages; CubeSQL backend version emitting a different format.
Related errors
- parsed.error
- Invalid response format
- CubeSQL query timed out after ${timeoutMs}ms
- CubeSQL query was aborted
- Transport does not support streaming
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/9e088538542da68a.
Report an issue: GitHub.