{"record":{"id":"2dcba6786a6ed5c0","repo":"payloadcms/payload","slug":"you-are-not-allowed-to-perform-this-action-2dcba6","errorCode":null,"errorMessage":"You are not allowed to perform this action.","messagePattern":"You are not allowed to perform this action\\.","errorType":"http","errorClass":"Forbidden","httpStatus":403,"severity":"error","filePath":"packages/payload/src/collections/operations/findVersionByID.ts","lineNumber":129,"sourceCode":"    const versionsQuery = await payload.db.findVersions<TData>({\n      collection: collectionConfig.slug,\n      limit: 1,\n      locale: locale!,\n      pagination: false,\n      req,\n      select,\n      where: fullWhere,\n    })\n\n    let result = versionsQuery.docs[0]!\n\n    if (!result) {\n      if (!disableErrors) {\n        if (!hasWhereAccess) {\n          throw new NotFound(req.t)\n        }\n        if (hasWhereAccess) {\n          throw new Forbidden(req.t)\n        }\n      }\n\n      return null!\n    }\n\n    if (!result.version) {\n      // Fallback if not selected\n      ;(result as any).version = {}\n    }\n\n    // /////////////////////////////////////\n    // beforeRead - Collection\n    // /////////////////////////////////////\n\n    if (collectionConfig.hooks?.beforeRead?.length) {\n      for (const hook of collectionConfig.hooks.beforeRead) {\n        result.version =","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/findVersionByID.ts#L111-L147","documentation":"In `findVersionByIDOperation`, if the version is not found AND `hasWhereAccess` is true, it throws `Forbidden`. The user's `access.readVersions` returned a where-constraint that excluded this version, so access is denied.","triggerScenarios":"`findVersionByID` where the user's `access.readVersions` returns a where clause and no version matches both the requested ID and that access constraint.","commonSituations":"Role-based version access; a user lacking permission to view versions of another user's documents.","solutions":["Ensure the user has `readVersions` access for that document.","Use `overrideAccess: true` in privileged contexts.","Adjust the `access.readVersions` function if it is too restrictive."],"exampleFix":"// before\nawait payload.findVersionByID({ collection: 'posts', id })\n// after (privileged)\nawait payload.findVersionByID({ collection: 'posts', id, overrideAccess: true })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isForbidden(e): boolean {\n  return e?.statusCode === 403 || e?.name === 'Forbidden'\n}","tryCatchPattern":"try {\n  return await payload.findVersionByID({ collection, id })\n} catch (e) {\n  if (isForbidden(e)) return null\n  throw e\n}","preventionTips":["Gate version-view UI on the user's `readVersions` permission.","Handle `Forbidden` gracefully rather than surfacing it raw."],"tags":["versions","access-control","forbidden"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}