{"record":{"id":"2befe4034b7e84b0","repo":"payloadcms/payload","slug":"the-following-path-results-length-1-s","errorCode":null,"errorMessage":"The following path${results.length === 1 ? '' : 's'} cannot be queried: ${results.map((err) => err.path).join(', ')}","messagePattern":"The following path(.+?) cannot be queried: (.+?)","errorType":"validation","errorClass":"QueryError","httpStatus":400,"severity":"error","filePath":"packages/payload/src/database/queryValidation/validateQueryPaths.ts","lineNumber":115,"sourceCode":"                overrideAccess,\n                path,\n                policies,\n                polymorphicJoin,\n                req,\n                val,\n                versionFields,\n              }),\n            )\n          } else {\n            errors.push({ path: `${path}.${operator}` })\n          }\n        }\n      }\n    }\n\n    await Promise.all(promises)\n    if (errors.length > 0) {\n      throw new QueryError(errors)\n    }\n  }\n}\n","sourceCodeStart":97,"sourceCodeEnd":119,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/database/queryValidation/validateQueryPaths.ts#L97-L119","documentation":"Thrown by `validateQueryPaths` as a `QueryError` when one or more `where` paths or operators are not queryable. Payload walks each `where` clause, resolves the field path against the collection/global/version fields, and validates the operator against the field type; any unresolved path or unsupported operator is collected into an `errors` array and, if non-empty, raised. The message lists every offending path.","triggerScenarios":"Querying `where[nonExistentField][equals]=x`; using `near` on a non-point field; querying a path inside a block/array that isn't indexed for queries; using an operator the field type disallows (e.g. `contains` on a number).","commonSituations":"Dynamic client-side filters building paths from user input; querying nested array/block fields that Payload does not expose for where-clauses; version mismatches after renaming a field without updating API consumers.","solutions":["Read the listed paths in the error and remove or correct each one.","Cross-check field names against the collection config (flattened/indexed fields only).","If filtering nested data, denormalize into a top-level indexed field or query in code after fetch."],"exampleFix":"// before\npayload.find({ collection: 'posts', where: { nonExistent: { equals: 'x' } } })\n// after\npayload.find({ collection: 'posts', where: { title: { equals: 'x' } } })","handlingStrategy":"try-catch","validationCode":"// Allowlist queryable field paths before building the where clause\nconst allowed = new Set(['title', 'status', 'createdAt'])\nfunction cleanWhere(where: Record<string, any>) {\n  return Object.fromEntries(Object.entries(where).filter(([k]) => allowed.has(k)))\n}","typeGuard":"function isQueryablePath(path: string, allowed: Set<string>): boolean {\n  return allowed.has(path)\n}","tryCatchPattern":"try {\n  await payload.find({ collection, where })\n} catch (err) {\n  if (err instanceof QueryError) {\n    // err.data.errors lists invalid paths — strip them and retry, or 400 the client\n  }\n  throw err\n}","preventionTips":["Allowlist field names when building `where` from user input.","Keep API consumers in sync after renaming queryable fields.","Unit-test dynamic filters against the collection schema."],"tags":["database","query","validation","where","rest-api"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}