{"record":{"id":"ed5d46081c18618d","repo":"cube-js/cube","slug":"invalid-query-format-error-message-error-tos-ed5d46","errorCode":null,"errorMessage":"Invalid query format: ${error.message || error.toString()}","messagePattern":"Invalid query format: (.+?)","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-api-gateway/src/query.js","lineNumber":440,"sourceCode":"  query.cache = undefined;\n\n  return query;\n}\n\n/**\n * Normalize incoming network query.\n * @param {Query} query\n * @param {boolean} persistent\n * @param {CacheMode} [cacheMode]\n * @throws {UserError}\n * @returns {import('./types/query').NormalizedQuery}\n */\nconst normalizeQuery = (query, persistent, cacheMode) => {\n  query = normalizeQueryCacheMode(query, cacheMode);\n  query.timezone = query.timezone || getEnv('defaultTimezone');\n  const { error, value } = querySchema.validate(query);\n  if (error) {\n    throw new UserError(`Invalid query format: ${error.message || error.toString()}`);\n  }\n\n  const validQuery = query.measures?.length ||\n    query.dimensions?.length ||\n    query.timeDimensions?.filter(td => !!td.granularity).length;\n  if (!validQuery) {\n    throw new UserError(\n      'Query should contain either measures, dimensions or timeDimensions with granularities in order to be valid'\n    );\n  }\n\n  const regularToTimeDimension = (query.dimensions || []).filter(d => typeof d === 'string' && d.split('.').length === 3).map(d => ({\n    dimension: d.split('.').slice(0, 2).join('.'),\n    granularity: d.split('.')[2]\n  }));\n  const timezone = value.timezone || 'UTC';\n\n  const def = getEnv('dbQueryDefaultLimit') <= getEnv('dbQueryLimit')","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-api-gateway/src/query.js#L422-L458","documentation":"Input validation in normalizeQuery: the submitted query object failed Joi validation against querySchema. It fires for any malformed query field — wrong types (e.g. measures as string instead of array), unknown keys, or invalid values — before any further normalization occurs.","triggerScenarios":"Thrown at packages/cubejs-api-gateway/src/query.js:440 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the Joi error message embedded in the error; it pinpoints the offending query key and expected type.","Ensure measures, dimensions, and timeDimensions are arrays of strings/objects as documented.","Remove unknown properties from the query object; the schema rejects unexpected keys."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}