{"record":{"id":"be8546cf12dc4bae","repo":"payloadcms/payload","slug":"the-following-path-results-length-1-s-be8546","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/sanitizeJoinQuery.ts","lineNumber":152,"sourceCode":"\n  for (const join of collectionConfig.polymorphicJoins) {\n    for (const collectionSlug of join.field.collection) {\n      await sanitizeJoinFieldQuery({\n        collectionSlug,\n        errors,\n        join,\n        joinsQuery,\n        overrideAccess,\n        promises,\n        req,\n      })\n    }\n  }\n\n  await Promise.all(promises)\n\n  if (errors.length > 0) {\n    throw new QueryError(errors)\n  }\n\n  return joinsQuery\n}\n","sourceCodeStart":134,"sourceCodeEnd":157,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/database/sanitizeJoinQuery.ts#L134-L157","documentation":"Thrown by `sanitizeJoinQuery` as a `QueryError` when a `joins` query parameter references join paths that are invalid. Payload validates each `joins[...]` path against the collection's configured `joins` and `polymorphicJoins`; unresolved or disallowed join paths accumulate into an `errors` array and are raised together. This is the join-query counterpart to `where`-path validation.","triggerScenarios":"Passing `joins[invalidPath]=x` for a path that is not a configured join field; joining through a polymorphic join with a path the target collection rejects; typo in the join field name.","commonSituations":"Frontend building `joins` params dynamically from field names; misconfiguring a join field; querying after a join field rename.","solutions":["Use only join field paths declared in the collection config.","Check the error's listed paths and remove unmatched ones.","After renaming a join field, update every consumer that builds `joins` params."],"exampleFix":"// before\npayload.find({ collection: 'posts', joins: { 'wrongName': { ... } } })\n// after\npayload.find({ collection: 'posts', joins: { 'comments': { ... } } })","handlingStrategy":"try-catch","validationCode":"// Allowlist join field names before building the joins param\nconst joinFields = new Set(['comments', 'tags'])\nfunction cleanJoins(joins: Record<string, any>) {\n  return Object.fromEntries(Object.entries(joins).filter(([k]) => joinFields.has(k)))\n}","typeGuard":"function isJoinField(name: string, cfg: { joins?: Record<string, unknown[]> }): boolean {\n  return Boolean(cfg.joins && cfg.joins[name])\n}","tryCatchPattern":"try {\n  await payload.find({ collection, joins })\n} catch (err) {\n  if (err instanceof QueryError) {\n    // remove the invalid join paths listed in err.data.errors, then retry\n  }\n  throw err\n}","preventionTips":["Only pass join paths that exist in the collection config.","Update consumers after renaming a join field.","Validate joins params at the API boundary."],"tags":["database","query","join","validation","rest-api"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}