cube-js/cube · error
Invalid response format
Error message
Invalid response format
What it means
cubeSql() expects the failed response to carry an `error` field. When the transport resolves with a null response or a response lacking `error`, the method cannot classify the failure and throws 'Invalid response format'. It guards the error-handling path itself.
Source
Thrown at packages/cubejs-client-core/src/index.ts:807
throwContinueWait: true,
};
if (options?.cache) {
cubesqlParams.cache = options.cache;
}
if (options?.timezone) {
cubesqlParams.timezone = options.timezone;
}
const request = this.request('cubesql', cubesqlParams);
return request;
},
(response: any) => {
// TODO: The response is sending both errors and successful results as `error`
if (!response || !response.error) {
throw new Error('Invalid response format');
}
// 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) {View on GitHub (pinned to 7d981676b3)
Solutions
- Check the transport used; use a supported HttpTransport from cubejs-client-core
- Upgrade cubejs-client-core and transport packages to matching versions
- Log the raw response before calling cubeSql to see what the transport actually returns
Example fix
// before
const client = new CubejsClient({ apiUrl, transport: myCustomTransport });
// after
const client = new CubejsClient({ apiUrl }); // default HttpTransport sets error correctly Defensive patterns
Strategy: try-catch
Validate before calling
const client = new CubejsClient({ apiUrl }); // use supported built-in transport Type guard
function isClassifiableError(res) {
return res != null && typeof res === 'object' && typeof res.error === 'string';
} Try / catch
try { const res = await client.cubeSql(sql); } catch (e) {
if (e.message === 'Invalid response format') {
console.error('Transport returned unexpected payload; check transport version/implementation', e);
} else throw e;
} Prevention
- Use built-in HttpTransport rather than ad-hoc transports
- Keep client and transport packages on the same version
- Log raw transport responses when debugging
When it happens
Trigger: Calling cubeSql() when the transport error callback receives undefined/null, or an object without an `error` property (e.g. a transport that resolves errors differently or resolves empty bodies).
Common situations: Custom or older transport implementations not setting `error` on failure; proxies/gateways returning empty bodies with non-200 statuses; version mismatches between client-core and transport packages.
Related errors
- Transport does not support streaming
- Unsupported response body type for streaming
- CubeSQL query timed out after ${timeoutMs}ms
- CubeSQL query was aborted
- response.error
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/796e68fee3f7ee45.
Report an issue: GitHub.