{"record":{"id":"51172e4a0d6b8341","repo":"payloadcms/payload","slug":"the-collection-with-slug-string-collectionslug-51172e","errorCode":null,"errorMessage":"The collection with slug ${String(collectionSlug)} can't be found. Find Version By ID Operation.","messagePattern":"The collection with slug (.+?) can't be found\\. Find Version By ID Operation\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/payload/src/collections/operations/local/findVersionByID.ts","lineNumber":108,"sourceCode":"  payload: Payload,\n  options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromCollectionSlug<TSlug>>> {\n  const {\n    id,\n    collection: collectionSlug,\n    depth,\n    disableErrors = false,\n    overrideAccess = true,\n    populate,\n    select,\n    showHiddenFields,\n    trash = false,\n  } = options\n\n  const collection = payload.collections[collectionSlug]\n\n  if (!collection) {\n    throw new APIError(\n      `The collection with slug ${String(\n        collectionSlug,\n      )} can't be found. Find Version By ID Operation.`,\n    )\n  }\n\n  return findVersionByIDOperation({\n    id,\n    collection,\n    depth,\n    disableErrors,\n    overrideAccess,\n    populate,\n    req: await createLocalReq(options as CreateLocalReqOptions, payload),\n    select,\n    showHiddenFields,\n    trash,\n  })","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/local/findVersionByID.ts#L90-L126","documentation":"Thrown by the Local API `findVersionByID` wrapper in packages/payload/src/collections/operations/local/findVersionByID.ts:108 when `payload.findVersionByID({ collection, id })` targets a slug not in `payload.collections`. Defaults to HTTP 500. Only relevant for versioned collections.","triggerScenarios":"Calling `payload.findVersionByID({ collection: 'page', id: versionId })` with a typo (real slug `'pages'`); querying a version after the collection's `versions` config was disabled or the collection removed; calling before `payload.init()`.","commonSituations":"Slug typo; collection rename; versions disabled so the slug path is stale; `as CollectionSlug` cast.","solutions":["Confirm the slug matches the collection config exactly.","Verify the collection still has versions enabled.","Check `Object.keys(payload.collections)` at runtime.","Remove `as CollectionSlug` casts on dynamic strings."],"exampleFix":"// before\nawait payload.findVersionByID({ collection: 'page', id: versionId }) // slug is 'pages'\n\n// after\nawait payload.findVersionByID({ collection: 'pages', id: versionId })","handlingStrategy":"validation","validationCode":"function assertCollectionSlug(payload: Payload, slug: string): void {\n  if (!(slug in payload.collections)) {\n    throw new Error(`Unknown collection slug '${slug}'`)\n  }\n}\nassertCollectionSlug(payload, 'pages')\nawait payload.findVersionByID({ collection: 'pages', id: versionId })","typeGuard":"const slugIsRegistered = (payload: Payload, slug: string): slug is CollectionSlug =>\n  slug in (payload.collections as Record<string, unknown>)\n\nif (slugIsRegistered(payload, slug)) {\n  await payload.findVersionByID({ collection: slug, id: versionId })\n}","tryCatchPattern":"try {\n  await payload.findVersionByID({ collection: slug, id: versionId })\n} catch (err) {\n  if (err instanceof APIError && /Find Version By ID Operation/.test(err.message)) {\n    // unknown slug — correct it\n  } else throw err\n}","preventionTips":["Confirm versions are enabled on the target collection.","Share slug constants between config and callers.","Avoid `as CollectionSlug` casts on dynamic input."],"tags":["local-api","collection","slug","versions","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}