{"record":{"id":"ae3091d05d514c99","repo":"payloadcms/payload","slug":"error-failed-to-retrieve-global-version-model-wit","errorCode":null,"errorMessage":"ERROR: Failed to retrieve global version model with the slug \"${globalSlug}\". Does not exist.","messagePattern":"ERROR: Failed to retrieve global version model with the slug \"(.+?)\"\\. Does not exist\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/db-mongodb/src/utilities/getEntity.ts","lineNumber":82,"sourceCode":"    globalConfig: SanitizedGlobalConfig\n    Model: CollectionModel\n  }\n}\n\nexport const getGlobal: GetGlobal = ({ adapter, globalSlug, versions = false }) => {\n  const globalConfig = adapter.payload.config.globals.find((each) => each.slug === globalSlug)\n\n  if (!globalConfig) {\n    throw new APIError(\n      `ERROR: Failed to retrieve global with the slug \"${globalSlug}\". Does not exist.`,\n    )\n  }\n\n  if (versions) {\n    const Model = adapter.versions[globalSlug]\n\n    if (!Model) {\n      throw new APIError(\n        `ERROR: Failed to retrieve global version model with the slug \"${globalSlug}\". Does not exist.`,\n      )\n    }\n\n    return { globalConfig, Model }\n  }\n\n  return { globalConfig, Model: adapter.globals } as any\n}\n","sourceCodeStart":64,"sourceCodeEnd":92,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/db-mongodb/src/utilities/getEntity.ts#L64-L92","documentation":"Thrown by `getGlobal` when `versions: true` is requested but `adapter.versions[globalSlug]` is undefined — the global versions model was never built. The global either does not have versions enabled, or the model build was skipped/raced.","triggerScenarios":"Calling a versions-aware global operation (`findGlobalVersions`, etc.) on a global whose config does not have `versions: true`, or before the versions models were built.","commonSituations":"`versions` not enabled on the global; config changed but process not restarted; init race.","solutions":["Enable `versions: true` on the global config.","Restart the process to rebuild versions models.","Await `payload.init()` before calling versions APIs.","If versions aren't enabled, use the non-versions global API."],"exampleFix":"// before\n{ slug: 'navigation', versions: false }\nawait payload.findGlobalVersions({ slug: 'navigation' })\n// after\n{ slug: 'navigation', versions: { drafts: true } }\nawait payload.findGlobalVersions({ slug: 'navigation' })","handlingStrategy":"validation","validationCode":"function assertGlobalVersions(payload, slug) {\n  const enabled = payload.config.globals.find(g => g.slug === slug)?.versions\n  if (!enabled) throw new Error(`Versions not enabled on global ${slug}`)\n}","typeGuard":"const globalHasVersions = (payload, s) =>\n  Boolean(payload.config.globals.find(g => g.slug === s)?.versions)","tryCatchPattern":"try { await payload.findGlobalVersions({ slug }) }\ncatch (e) { if (/global version model with the slug/.test(e.message)) enableGlobalVersions(slug) else throw e }","preventionTips":["Enable versions on globals you call versions APIs on.","Restart after enabling versions so models rebuild.","Use the non-versions global API when versions aren't enabled."],"tags":["mongodb","versions","globals","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}