{"record":{"id":"796e68fee3f7ee45","repo":"cube-js/cube","slug":"invalid-response-format","errorCode":null,"errorMessage":"Invalid response format","messagePattern":"Invalid response format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/index.ts","lineNumber":807,"sourceCode":"          throwContinueWait: true,\n        };\n\n        if (options?.cache) {\n          cubesqlParams.cache = options.cache;\n        }\n\n        if (options?.timezone) {\n          cubesqlParams.timezone = options.timezone;\n        }\n\n        const request = this.request('cubesql', cubesqlParams);\n\n        return request;\n      },\n      (response: any) => {\n        // TODO: The response is sending both errors and successful results as `error`\n        if (!response || !response.error) {\n          throw new Error('Invalid response format');\n        }\n\n        // Check if this is a timeout or abort error from transport\n        if (response.error === 'timeout') {\n          const timeoutMs = options?.timeout || 5 * 60 * 1000;\n          throw new Error(`CubeSQL query timed out after ${timeoutMs}ms`);\n        }\n\n        if (response.error === 'aborted') {\n          throw new Error('CubeSQL query was aborted');\n        }\n\n        const [schema, ...data] = response.error.split('\\n');\n\n        let parsedSchema: any;\n        try {\n          parsedSchema = JSON.parse(schema);\n        } catch (err) {","sourceCodeStart":789,"sourceCodeEnd":825,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/index.ts#L789-L825","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nconst client = new CubejsClient({ apiUrl, transport: myCustomTransport });\n// after\nconst client = new CubejsClient({ apiUrl }); // default HttpTransport sets error correctly","handlingStrategy":"try-catch","validationCode":"const client = new CubejsClient({ apiUrl }); // use supported built-in transport","typeGuard":"function isClassifiableError(res) {\n  return res != null && typeof res === 'object' && typeof res.error === 'string';\n}","tryCatchPattern":"try { const res = await client.cubeSql(sql); } catch (e) {\n  if (e.message === 'Invalid response format') {\n    console.error('Transport returned unexpected payload; check transport version/implementation', e);\n  } else throw e;\n}","preventionTips":["Use built-in HttpTransport rather than ad-hoc transports","Keep client and transport packages on the same version","Log raw transport responses when debugging"],"tags":["cubesql","response-format","transport"],"backgroundTag":"invalid-response-format","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}