{"record":{"id":"38da9c159f10a09c","repo":"payloadcms/payload","slug":"the-collection-with-slug-string-collectionslug-38da9c","errorCode":null,"errorMessage":"The collection with slug ${String(collectionSlug)} can't be found. Restore Version Operation.","messagePattern":"The collection with slug (.+?) can't be found\\. Restore Version Operation\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/payload/src/collections/operations/local/restoreVersion.ts","lineNumber":91,"sourceCode":"\nexport async function restoreVersionLocal<TSlug extends CollectionSlug>(\n  payload: Payload,\n  options: Options<TSlug>,\n): Promise<DataFromCollectionSlug<TSlug>> {\n  const {\n    id,\n    collection: collectionSlug,\n    depth,\n    overrideAccess = true,\n    populate,\n    select,\n    showHiddenFields,\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. Restore Version Operation.`,\n    )\n  }\n\n  const args = {\n    id,\n    collection,\n    depth,\n    overrideAccess,\n    payload,\n    populate,\n    req: await createLocalReq(options as CreateLocalReqOptions, payload),\n    select,\n    showHiddenFields,\n  }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/local/restoreVersion.ts#L73-L109","documentation":"Thrown by the Local API `restoreVersion` wrapper in packages/payload/src/collections/operations/local/restoreVersion.ts:91 when `payload.restoreVersion({ collection, id })` targets a slug not registered in `payload.collections`. Defaults to HTTP 500. Only meaningful for versioned collections.","triggerScenarios":"Calling `payload.restoreVersion({ collection: 'page', id: versionId })` with a typo; restoring a version after the collection was renamed or its versions config removed; calling before `payload.init()`.","commonSituations":"Slug typo; collection renamed; versions disabled; `as CollectionSlug` cast on a dynamic slug.","solutions":["Confirm the slug matches the collection config exactly.","Verify the collection still has versions enabled (otherwise there is nothing to restore).","Check `Object.keys(payload.collections)` at runtime.","Remove `as CollectionSlug` casts on dynamic strings."],"exampleFix":"// before\nawait payload.restoreVersion({ collection: 'page', id: versionId }) // slug is 'pages'\n\n// after\nawait payload.restoreVersion({ 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.restoreVersion({ 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.restoreVersion({ collection: slug, id: versionId })\n}","tryCatchPattern":"try {\n  await payload.restoreVersion({ collection: slug, id: versionId })\n} catch (err) {\n  if (err instanceof APIError && /Restore Version Operation/.test(err.message)) {\n    // unknown slug — correct it\n  } else throw err\n}","preventionTips":["Confirm versions are enabled before attempting restore.","Keep slug constants centralized.","Avoid `as CollectionSlug` casts on dynamic strings."],"tags":["local-api","collection","slug","versions","restore","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}