{"record":{"id":"e19df6bce8c5e1e6","repo":"payloadcms/payload","slug":"collection-config-for-join-field-collection-tost","errorCode":null,"errorMessage":"Collection config for ${join.field.collection.toString()} was not found","messagePattern":"Collection config for (.+?) was not found","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/db-mongodb/src/utilities/buildJoinAggregation.ts","lineNumber":279,"sourceCode":"\n    if (!joinsList) {\n      throw new APIError(`Failed to retrieve array of joins for ${slug} in collectio ${collection}`)\n    }\n\n    for (const join of joinsList) {\n      const projectionPath = versions ? `version.${join.joinPath}` : join.joinPath\n      if (projection && !projection[projectionPath]) {\n        continue\n      }\n\n      if (joins?.[join.joinPath] === false) {\n        continue\n      }\n\n      const collectionConfig = adapter.payload.collections[join.field.collection as string]?.config\n\n      if (!collectionConfig) {\n        throw new APIError(\n          `Collection config for ${join.field.collection.toString()} was not found`,\n        )\n      }\n\n      let JoinModel: CollectionModel | undefined\n\n      const useDrafts = (draftsEnabled || versions) && hasDraftsEnabled(collectionConfig)\n\n      if (useDrafts) {\n        JoinModel = adapter.versions[collectionConfig.slug]\n      } else {\n        JoinModel = adapter.collections[collectionConfig.slug]\n      }\n\n      if (!JoinModel) {\n        throw new APIError(`Join Model was not found for ${collectionConfig.slug}`)\n      }\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/db-mongodb/src/utilities/buildJoinAggregation.ts#L261-L297","documentation":"Thrown while iterating individual joins when the join's target collection (`join.field.collection`) is not a key of `adapter.payload.collections`. The join points at a collection that is not registered at runtime, so no target config/model can be resolved.","triggerScenarios":"A `join` field whose `collection` value references a slug that doesn't exist — typo, the target collection was deleted/renamed, or the target is provided by a plugin that isn't loaded.","commonSituations":"Removing/renaming a collection that another collection joins into without updating join definitions; cross-plugin joins where the target plugin is not registered; slug casing mismatch.","solutions":["Check the join field's `collection` value matches a registered collection slug.","Update or remove stale join definitions referencing deleted collections.","Ensure the target collection/plugin is loaded before/alongside the source.","Search your config for `collection:` references to confirm they all resolve."],"exampleFix":"// before\n{ name: 'author', type: 'join', collection: 'users' } // 'Users' is the real slug\n// after\n{ name: 'author', type: 'join', collection: 'Users' }","handlingStrategy":"validation","validationCode":"function assertJoinTarget(payload, targetSlug) {\n  if (!payload.collections[targetSlug]) throw new Error(`Join target not registered: ${targetSlug}`)\n}","typeGuard":"const isRegisteredJoinTarget = (payload, target) =>\n  typeof target === 'string' && Boolean(payload.collections[target])","tryCatchPattern":"try { await payload.find({ collection, joins }) }\ncatch (e) { if (/Collection config for .* was not found/.test(e.message)) auditJoinTargets(collection) else throw e }","preventionTips":["Grep config for `collection:` join targets and confirm each resolves.","When renaming/deleting a collection, update all joins into it.","Load target collections/plugins before issuing join queries."],"tags":["mongodb","joins","collections","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}