{"record":{"id":"cbb4a6fffd887cc6","repo":"cube-js/cube","slug":"unknown-query-type","errorCode":null,"errorMessage":"Unknown query type","messagePattern":"Unknown query type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/ResultSet.ts","lineNumber":132,"sourceCode":"  public constructor(loadResponse: LoadResponse<T> | LoadResponseResult<T>, options: ResultSetOptions = {}) {\n    if ('queryType' in loadResponse && loadResponse.queryType != null) {\n      this.loadResponse = loadResponse;\n      this.queryType = loadResponse.queryType;\n      this.loadResponses = loadResponse.results;\n    } else {\n      this.queryType = QUERY_TYPE.REGULAR_QUERY;\n      this.loadResponse = {\n        ...loadResponse,\n        pivotQuery: {\n          ...loadResponse.query,\n          queryType: this.queryType\n        }\n      } as LoadResponse<T>;\n      this.loadResponses = [loadResponse as LoadResponseResult<T>];\n    }\n\n    if (!Object.values(QUERY_TYPE).includes(this.queryType)) {\n      throw new Error('Unknown query type');\n    }\n\n    this.parseDateMeasures = options.parseDateMeasures;\n    this.options = options;\n\n    this.backwardCompatibleData = [];\n  }\n\n  /**\n   * Returns a measure drill down query.\n   *\n   * Provided you have a measure with the defined `drillMembers` on the `Orders` cube\n   * ```js\n   * measures: {\n   *   count: {\n   *     type: `count`,\n   *     drillMembers: [Orders.status, Users.city, count],\n   *   },","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/ResultSet.ts#L114-L150","documentation":"The ResultSet constructor reads queryType from the load response (defaulting to REGULAR_QUERY when absent) and validates it against the QUERY_TYPE enum values ('regular', 'compareDateRange', 'blending'). If queryType is set but not one of these, it throws 'Unknown query type'. This guards against constructing a ResultSet from a corrupted, hand-crafted, or version-mismatched load response.","triggerScenarios":"new ResultSet(loadResponse) or ResultSet.deserialize(serialized) where loadResponse.queryType is set but not a valid QUERY_TYPE value — e.g. a newer server emitting an unseen queryType string, a manually assembled object with queryType: 'regularQuery' instead of 'regular', a typo like 'blended', or corrupted JSON after round-tripping.","commonSituations":"Deserializing stored results that were hand-edited; client/server version mismatch where the server emits a queryType the older client does not know; custom code constructing ResultSet from a raw REST response and guessing the queryType value instead of omitting it.","solutions":["Remove the queryType property (or pass a plain load response) so the constructor defaults to REGULAR_QUERY, unless you truly have a compareDateRange/blending response.","Use valid values only: 'regular', 'compareDateRange', 'blending' — or better, let the API response supply it.","Upgrade @cubejs-client-core so its QUERY_TYPE enum matches the server's response format.","Only pass results of resultSet.serialize() to deserialize — not hand-modified JSON."],"exampleFix":"// before\nconst rs = new ResultSet({ ...loadResponse, queryType: 'regularQuery' }); // throws 'Unknown query type'\n\n// after\nconst rs = new ResultSet(loadResponse); // queryType omitted -> defaults to REGULAR_QUERY","handlingStrategy":"validation","validationCode":"const VALID_QUERY_TYPES = ['regular', 'compareDateRange', 'blending'];\nfunction validateLoadResponse(lr) {\n  if ('queryType' in lr && lr.queryType != null && !VALID_QUERY_TYPES.includes(lr.queryType)) {\n    throw new Error(`Invalid queryType: ${lr.queryType}`);\n  }\n  return lr;\n}\nconst rs = new ResultSet(validateLoadResponse(loadResponse));","typeGuard":"function isKnownQueryType(qt: unknown): qt is 'regular' | 'compareDateRange' | 'blending' {\n  return qt == null || ['regular', 'compareDateRange', 'blending'].includes(qt as string);\n}","tryCatchPattern":"let resultSet;\ntry {\n  resultSet = new ResultSet(loadResponse);\n} catch (e) {\n  if (e.message === 'Unknown query type') {\n    resultSet = new ResultSet({ ...loadResponse, queryType: undefined }); // default to regular\n  } else { throw e; }\n}","preventionTips":["Never hand-set queryType on load responses; omit it and let the constructor default to REGULAR_QUERY.","Only pass results of resultSet.serialize() to ResultSet.deserialize/constructor.","Keep @cubejs-client-core in sync with your Cube server version so QUERY_TYPE values match.","Validate stored/serialized payloads before rehydrating ResultSets."],"tags":["typescript","resultset","deserialization","query-type"],"backgroundTag":"invalid-enum-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}