{"record":{"id":"62c4c2d701b30128","repo":"payloadcms/payload","slug":"not-found-62c4c2","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"packages/payload/src/globals/operations/findOne.ts","lineNumber":100,"sourceCode":"      }\n    }\n\n    // /////////////////////////////////////\n    // Retrieve and execute access\n    // /////////////////////////////////////\n\n    let accessResult!: AccessResult\n\n    if (!overrideAccess) {\n      accessResult = await executeAccess(\n        { slug: globalConfig.slug, disableErrors, req },\n        globalConfig.access.read,\n      )\n    }\n\n    if (accessResult === false) {\n      if (!disableErrors) {\n        throw new NotFound(req.t)\n      }\n      return null!\n    }\n\n    const select = sanitizeSelect({\n      fields: globalConfig.flattenedFields,\n      select: resolveSelect({\n        config: globalConfig.select,\n        operation: 'read',\n        req,\n        select: incomingSelect,\n      }),\n    })\n\n    // /////////////////////////////////////\n    // Perform database operation\n    // /////////////////////////////////////\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/globals/operations/findOne.ts#L82-L118","documentation":"Reading a global where the access-control `read` policy returned `false` (and `disableErrors` is not set). Payload throws `NotFound` rather than `Forbidden` when access is denied for a global read, so the API does not leak the existence of a global the caller cannot see.","triggerScenarios":"Calling `payload.findGlobal({ slug, req })` (or the REST `GET /api/globals/<slug>`) as a user whose `access.read` returns `false`; calling from an unauthenticated request on a members-only global.","commonSituations":"Logged-out user hitting a restricted global; role-based read access that excludes the current user; front-end fetching a global before the session is established.","solutions":["Ensure the caller is authenticated and has read access per `globalConfig.access.read`.","If calling server-side where access is already authorized, pass `overrideAccess: true`.","Adjust the access function to allow the intended audience, or call with `disableErrors: true` to receive `null` instead of a throw."],"exampleFix":"// before (unauthenticated read of restricted global)\nawait payload.findGlobal({ slug: 'settings', req })\n// after (authenticate the user)\nawait payload.findGlobal({ slug: 'settings', req: authenticatedReq })\n// or server-side trusted call\nawait payload.findGlobal({ slug: 'settings', req, overrideAccess: true })","handlingStrategy":"try-catch","validationCode":"// before calling, gate on access yourself (server) or check auth state (client)\nfunction canReadGlobal(user, globalAccessRead) {\n  if (!globalAccessRead) return true // no policy\n  return Boolean(globalAccessRead({ req: { user } }))\n}\nif (!canReadGlobal(req.user, globalConfig.access?.read)) {\n  // skip the call, render 'unavailable', or authenticate\n}","typeGuard":"function isNotFound(err: any): err is { name: 'NotFound'; statusCode: number } {\n  return err?.name === 'NotFound' || err?.statusCode === 404\n}","tryCatchPattern":"try {\n  const g = await payload.findGlobal({ slug: 'settings', req })\n  return g\n} catch (err) {\n  if (err?.name === 'NotFound' || err?.statusCode === 404) {\n    // access denied or truly absent — treat as unavailable to the caller\n    return null\n  }\n  throw err\n}","preventionTips":["Call findGlobal with `overrideAccess: true` only in trusted server contexts.","Set `disableErrors: true` to receive `null` instead of a throw for optional reads.","Keep `access.read` deterministic and unit-tested per role."],"tags":["global","access-control","not-found","auth","runtime","api"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}