{"record":{"id":"00d05b57c7ee55d9","repo":"payloadcms/payload","slug":"the-global-with-slug-string-globalslug-can-t-b-00d05b","errorCode":null,"errorMessage":"The global with slug ${String(globalSlug)} can't be found.","messagePattern":"The global with slug (.+?) can't be found\\.","errorType":"exception","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/payload/src/globals/operations/local/findVersionByID.ts","lineNumber":96,"sourceCode":"export async function findGlobalVersionByIDLocal<TSlug extends GlobalSlug>(\n  payload: Payload,\n  options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> {\n  const {\n    id,\n    slug: globalSlug,\n    depth,\n    disableErrors = false,\n    overrideAccess = true,\n    populate,\n    select,\n    showHiddenFields,\n  } = options\n\n  const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n  if (!globalConfig) {\n    throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n  }\n\n  return findVersionByIDOperation({\n    id,\n    depth,\n    disableErrors,\n    globalConfig,\n    overrideAccess,\n    populate,\n    req: await createLocalReq(options as CreateLocalReqOptions, payload),\n    select,\n    showHiddenFields,\n  })\n}\n","sourceCodeStart":78,"sourceCodeEnd":111,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/globals/operations/local/findVersionByID.ts#L78-L111","documentation":"Thrown by findGlobalVersionByIDLocal when globalSlug is not in payload.globals.config, before delegating to findVersionByIDOperation. The Local API wrapper that backs payload.findGlobalVersionByID.","triggerScenarios":"Calling payload.findGlobalVersionByID({ id, slug: 'wrong' }) where the slug is not registered.","commonSituations":"Slug typo; renamed global; copy-paste; calling during boot before globals are sanitized.","solutions":["Guard the slug with a check against payload.globals.config.","Use the typed GlobalSlug parameter so invalid slugs fail at compile time.","Update callers after a rename; do not rely on silent null.","Verify Payload init completed."],"exampleFix":"// before\nconst v = await payload.findGlobalVersionByID({ slug: 'navigaton', id })\n\n// after\nconst exists = payload.globals.config.some(g => g.slug === slug)\nif (!exists) throw new Error(`Unknown global: ${slug}`)\nconst v = await payload.findGlobalVersionByID({ slug, id })","handlingStrategy":"validation","validationCode":"if (!payload.globals.config.some((g) => g.slug === slug)) {\n  throw new Error(`Unknown global: ${slug}`)\n}","typeGuard":"function isGlobalSlug(payload: Payload, slug: string): slug is GlobalSlug {\n  return payload.globals.config.some((g) => g.slug === slug)\n}","tryCatchPattern":"try {\n  return await payload.findGlobalVersionByID({ slug, id })\n} catch (err) {\n  if (err instanceof APIError && /can't be found/.test(err.message)) return null\n  throw err\n}","preventionTips":["Use typed GlobalSlug at every call site.","Verify versions are enabled on the target global before looking one up."],"tags":["globals","versions","local-api","config","validation"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}