{"record":{"id":"d678635d8f707bbe","repo":"payloadcms/payload","slug":"no-global-was-specified","errorCode":null,"errorMessage":"No global was specified","messagePattern":"No global was specified","errorType":"exception","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"packages/payload/src/utilities/getRequestEntity.ts","lineNumber":83,"sourceCode":"  }\n\n  // If we still should sanitize, parse float\n  if (shouldSanitize) {\n    sanitizedID = parseFloat(sanitizedID)\n  }\n\n  return {\n    // @ts-expect-error generic return\n    id: sanitizedID,\n    collection,\n  }\n}\n\nexport const getRequestGlobal = (req: PayloadRequest): SanitizedGlobalConfig => {\n  const globalSlug = req.routeParams?.global\n\n  if (typeof globalSlug !== 'string') {\n    throw new APIError(`No global was specified`, 400)\n  }\n\n  const globalConfig = req.payload.globals.config.find((each) => each.slug === globalSlug)\n\n  if (!globalConfig) {\n    throw new APIError(`Global with the slug ${globalSlug} was not found`, 404)\n  }\n\n  return globalConfig\n}\n","sourceCodeStart":65,"sourceCodeEnd":94,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/utilities/getRequestEntity.ts#L65-L94","documentation":"Thrown by `getRequestGlobal` when `req.routeParams.global` is absent or not a string. This utility resolves the target global from the request route parameters on global-scoped REST endpoints (e.g. `/api/globals/:global`).","triggerScenarios":"A request reaches a global-resolution path but the route was matched without populating `routeParams.global`. Typically a misconfigured custom route, a middleware that strips route params, or an internal call missing the param.","commonSituations":"A custom handler forwards to Payload global REST layer without setting route params; a URL rewrite removed the global slug segment; an internal Local API call constructed a synthetic request without `routeParams.global`; a custom route pattern that fails to capture the global slug.","solutions":["Ensure the request URL includes the global slug segment and the route captures it into `routeParams.global`.","If calling the REST layer programmatically, set `req.routeParams = { global: 'yourGlobalSlug' }` on the synthetic request.","Verify no middleware clears `req.routeParams` before Payload processes the request.","Use the Local API (`payload.findGlobal`, `payload.updateGlobal`) instead of constructing raw requests when possible."],"exampleFix":"// before -- custom handler forwards without routeParams\napp.get('/api/site-config', (req, res) => payloadGlobalHandler(req, res))\n\n// after\napp.get('/api/globals/:global', (req, res, next) => {\n  req.routeParams = { global: req.params.global }\n  next()\n})","handlingStrategy":"validation","validationCode":"// Before forwarding to Payload REST, ensure routeParams.global is set\nif (typeof req.routeParams?.global !== 'string') {\n  throw new Error('Missing global slug in route params')\n}","typeGuard":"const hasGlobalParam = (req) => typeof req.routeParams?.global === 'string'","tryCatchPattern":"try {\n  globalConfig = getRequestGlobal(req)\n} catch (e) {\n  if (e instanceof APIError && e.message === 'No global was specified') {\n    // set req.routeParams.global and retry, or return 400\n  } else throw e\n}","preventionTips":["Always set req.routeParams.global when constructing synthetic requests for global endpoints.","Use the Local API (payload.findGlobal / payload.updateGlobal) for programmatic operations.","Verify custom route patterns capture the global slug parameter."],"tags":["routing","global","request","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}