{"record":{"id":"8b6efaf47f208745","repo":"cube-js/cube","slug":"parsed-error","errorCode":null,"errorMessage":"parsed.error","messagePattern":"parsed\\.error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/index.ts","lineNumber":849,"sourceCode":"\n        for (const line of data) {\n          if (line.trim().length) {\n            let parsed: any;\n            try {\n              parsed = JSON.parse(line);\n            } catch (err) {\n              // A non-JSON line after a valid schema means a malformed payload — fall\n              // back to surfacing the raw response rather than dropping rows silently.\n              throw new Error(response.error);\n            }\n\n            // The stream can interleave an error chunk after the schema (e.g. a\n            // post-processing/cast error surfaced mid-result). Such a line has no\n            // `data`, so the previous `JSON.parse(d).data` concat pushed an `undefined`\n            // \"phantom\" row and silently swallowed the failure. Surface it instead —\n            // matching how `cubeSqlStream` classifies `error` chunks.\n            if (parsed.error) {\n              throw new Error(parsed.error);\n            }\n\n            if (parsed.data) {\n              // Append rows one at a time instead of spreading the whole chunk as\n              // call arguments (`rows.push(...parsed.data)`). A large single-chunk\n              // result (e.g. 130k+ rows) otherwise exceeds V8's argument-count\n              // limit and throws \"RangeError: Maximum call stack size exceeded\".\n              for (let i = 0; i < parsed.data.length; i++) {\n                rows.push(parsed.data[i]);\n              }\n            }\n          }\n        }\n\n        return {\n          schema: parsedSchema.schema,\n          data: rows,\n          ...(parsedSchema.lastRefreshTime ? { lastRefreshTime: parsedSchema.lastRefreshTime } : {}),","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/index.ts#L831-L867","documentation":"A JSON line after the schema containing an `error` key (and no `data`) represents a mid-stream failure (e.g. a post-processing/cast error). cubeSql() surfaces parsed.error instead of pushing a phantom undefined row.","triggerScenarios":"Server emits an error chunk after results started streaming — e.g. type-cast or post-processing failure partway through a result set.","commonSituations":"Data that fails casting mid-result; server-side errors occurring after initial rows; schema/data mismatch in the cube model.","solutions":["Fix the underlying server error reported in parsed.error (often a data type/cast problem)","Review cube schema member types vs actual column types","Retry the query to confirm whether it is deterministic"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isErrorChunk(parsed) {\n  return parsed != null && typeof parsed === 'object' && typeof parsed.error === 'string';\n}","tryCatchPattern":"try { const res = await client.cubeSql(sql); } catch (e) {\n  console.error('Mid-stream CubeSQL error:', e.message);\n}","preventionTips":["Align cube member types with underlying column types","Test queries over representative data to catch cast failures","Keep server and client formats in sync via version pinning"],"tags":["cubesql","streaming","server-error"],"backgroundTag":"invalid-response-format","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}