{"record":{"id":"e25e1196b4773f8f","repo":"payloadcms/payload","slug":"not-found-e25e11","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"packages/payload/src/globals/operations/restoreVersion.ts","lineNumber":72,"sourceCode":"    // /////////////////////////////////////\n\n    if (!overrideAccess) {\n      await executeAccess({ slug: globalConfig.slug, req }, globalConfig.access.update)\n    }\n\n    // /////////////////////////////////////\n    // Retrieve original raw version\n    // /////////////////////////////////////\n\n    const { docs: versionDocs } = await payload.db.findGlobalVersions<any>({\n      global: globalConfig.slug,\n      limit: 1,\n      req,\n      where: { id: { equals: id } },\n    })\n\n    if (!versionDocs || versionDocs.length === 0) {\n      throw new NotFound(req.t)\n    }\n\n    const rawVersion = versionDocs[0]!\n\n    // Patch globalType onto version doc\n    rawVersion.version.globalType = globalConfig.slug\n\n    // Overwrite draft status if draft is true\n\n    if (draft) {\n      rawVersion.version._status = 'draft'\n    }\n    // /////////////////////////////////////\n    // fetch previousDoc\n    // /////////////////////////////////////\n\n    const previousDoc = await payload.findGlobal({\n      slug: globalConfig.slug,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/globals/operations/restoreVersion.ts#L54-L90","documentation":"Thrown by restoreVersionOperation when the underlying payload.db.findGlobalVersions query for the requested id returns zero docs. The version to restore does not exist in the versions table. Surfaced as NotFound (HTTP 404).","triggerScenarios":"POST /globals/:slug/versions/:id/restore or payload.restoreGlobalVersion with an id that has no matching version row, including after the version was purged or belongs to a different global.","commonSituations":"Restoring from a stale link after a version was deleted; passing a doc id instead of a version id; versions table truncated by a retention job.","solutions":["Verify the version exists via findGlobalVersions({ where: { id: { equals } } }) before restoring.","In UI flows, disable the restore button once the version is gone and refresh the list.","Distinguish version ids (from the versions endpoint) from document/global ids.","Configure version retention so you know when versions disappear."],"exampleFix":"// before\nawait payload.restoreGlobalVersion({ slug, id })\n\n// after\nconst { docs } = await payload.findGlobalVersions({\n  slug,\n  where: { id: { equals: id } },\n  limit: 1,\n})\nif (docs.length === 0) throw new Error('version gone')\nawait payload.restoreGlobalVersion({ slug, id })","handlingStrategy":"validation","validationCode":"const { docs } = await payload.findGlobalVersions({\n  slug,\n  where: { id: { equals: id } },\n  limit: 1,\n})\nif (!docs.length) throw new Error('version not found')","typeGuard":"function versionExists(list: { id?: string | number }[], id: string | number) {\n  return list.some((v) => String(v.id) === String(id))\n}","tryCatchPattern":"try {\n  await payload.restoreGlobalVersion({ slug, id })\n} catch (err) {\n  if (err instanceof NotFound) return null\n  throw err\n}","preventionTips":["Disable the restore action when the version is no longer in the list.","Do not confuse document/global ids with version ids."],"tags":["globals","versions","not-found","restore"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}