{"record":{"id":"e2d58ca5ef8117a3","repo":"cube-js/cube","slug":"resultindex-is-required","errorCode":null,"errorMessage":"resultIndex is required","messagePattern":"resultIndex is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/ResultSet.ts","lineNumber":1142,"sourceCode":"  public rawData(): T[] {\n    if (this.queryType !== QUERY_TYPE.REGULAR_QUERY) {\n      throw new Error(`Method is not supported for a '${this.queryType}' query type. Please use decompose`);\n    }\n\n    return this.loadResponses[0].data;\n  }\n\n  public annotation(): QueryAnnotations {\n    if (this.queryType !== QUERY_TYPE.REGULAR_QUERY) {\n      throw new Error(`Method is not supported for a '${this.queryType}' query type. Please use decompose`);\n    }\n\n    return this.loadResponses[0].annotation;\n  }\n\n  private timeDimensionBackwardCompatibleData(resultIndex: number) {\n    if (resultIndex === undefined) {\n      throw new Error('resultIndex is required');\n    }\n\n    if (!this.backwardCompatibleData[resultIndex]) {\n      const { data, query } = this.loadResponses[resultIndex];\n      const timeDimensions = (query.timeDimensions || []).filter(td => Boolean(td.granularity));\n\n      this.backwardCompatibleData[resultIndex] = data.map(row => (\n        {\n          ...row,\n          ...(\n            fromPairs(Object.keys(row)\n              .filter(\n                field => {\n                  const foundTd = timeDimensions.find(d => d.dimension === field);\n                  return foundTd && !row[ResultSet.timeDimensionMember(foundTd)];\n                }\n              ).map(field => (\n                [ResultSet.timeDimensionMember(timeDimensions.find(d => d.dimension === field)!), row[field]]","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/ResultSet.ts#L1124-L1160","documentation":"timeDimensionBackwardCompatibleData() converts a specific sub-result's data into a backward-compatible format (flattening old date-column layouts). It requires an explicit resultIndex into loadResponses; a undefined index is a programming error, so the library throws immediately.","triggerScenarios":"Internal call paths passing an undefined resultIndex — practically triggered by calling private/underscore-style helpers directly or by constructing/mocking a ResultSet and invoking conversion logic without the index argument (e.g. custom subclasses or copied client code).","commonSituations":"Monkey-patching or extending ResultSet in app code; TypeScript transpiled older client versions where helpers were called manually; copy-pasted internal logic into application utilities.","solutions":["Pass the resultIndex explicitly (usually 0 for single-query results)","Stop calling this private helper directly; use public APIs (chartPivot/tablePivot/seriesNames)","If you must call it, default the argument: fn(resultIndex ?? 0)"],"exampleFix":"// before\ndataSet(rs.timeDimensionBackwardCompatibleData());\n// after\ndataSet(rs.timeDimensionBackwardCompatibleData(0));","handlingStrategy":"validation","validationCode":"function backwardCompatible(rs: ResultSet, resultIndex?: number) {\n  if (resultIndex === undefined) throw new TypeError('resultIndex is required');\n  return (rs as any).timeDimensionBackwardCompatibleData(resultIndex);\n}","typeGuard":null,"tryCatchPattern":"let data;\ntry { data = helper(resultIndex); } catch (e) {\n  if (String(e?.message) === 'resultIndex is required') {\n    data = helper(0); // single-query default\n  } else throw e;\n}","preventionTips":["Never call private ResultSet methods; use chartPivot/tablePivot/seriesNames","If you must reuse internals, always pass an explicit index (0 for single queries)","Enable strict TypeScript so missing required arguments are caught at compile time","Pin client versions when relying on internal behavior"],"tags":["internal-api","argument-validation","backward-compatibility","resultset"],"backgroundTag":"missing-required-argument","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}