{"record":{"id":"b71994876476fd2b","repo":"payloadcms/payload","slug":"error-failed-to-retrieve-global-with-the-slug","errorCode":null,"errorMessage":"ERROR: Failed to retrieve global with the slug \"${globalSlug}\". Does not exist.","messagePattern":"ERROR: Failed to retrieve global with the slug \"(.+?)\"\\. Does not exist\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/db-mongodb/src/utilities/getEntity.ts","lineNumber":73,"sourceCode":"  globalSlug: string\n}\n\ninterface GetGlobal {\n  (args: { versions?: false | undefined } & BaseGetGlobalArgs): {\n    globalConfig: SanitizedGlobalConfig\n    Model: GlobalModel\n  }\n  (args: { versions?: true } & BaseGetGlobalArgs): {\n    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}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/db-mongodb/src/utilities/getEntity.ts#L55-L91","documentation":"Thrown by `getGlobal` when `payload.config.globals.find()` returns no match for `globalSlug`. The global is not registered at runtime, so no config/model lookup can proceed.","triggerScenarios":"Any global operation (findGlobal, updateGlobal, etc.) with a `globalSlug` that is not in `payload.config.globals`.","commonSituations":"Slug typo; global renamed without updating callers; wrong config loaded in a multi-tenant setup; querying before init; REST path to a non-existent global.","solutions":["Verify the slug equals a `slug` in your `globals` config.","Confirm the global is registered and `payload.init()` resolved.","For dynamic slugs, validate against `payload.config.globals` first.","Check REST route spelling against the configured global slug."],"exampleFix":"// before\nawait payload.findGlobal({ slug: 'nav' }) // real slug is 'navigation'\n// after\nawait payload.findGlobal({ slug: 'navigation' })","handlingStrategy":"validation","validationCode":"function assertGlobalExists(payload, slug) {\n  if (!payload.config.globals.some(g => g.slug === slug))\n    throw new Error(`Global not registered: ${slug}`)\n}","typeGuard":"const isRegisteredGlobal = (payload, s) =>\n  typeof s === 'string' && payload.config.globals.some(g => g.slug === s)","tryCatchPattern":"try { await payload.findGlobal({ slug }) }\ncatch (e) { if (/Failed to retrieve global with the slug/.test(e.message)) handleUnknownGlobal(slug) else throw e }","preventionTips":["Use shared slug constants for globals across config and callers.","Await payload.init() before global operations.","Validate dynamic slugs against payload.config.globals."],"tags":["mongodb","globals","slug","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}