{"record":{"id":"f4410a64ba265787","repo":"RocketChat/Rocket.Chat","slug":"error-permission-not-found","errorCode":"error-permission-not-found","errorMessage":"Permission not found","messagePattern":"Permission not found","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/authorization/permissionRole.ts","lineNumber":61,"sourceCode":"\t\t\taction: 'Adding_permission',\n\t\t});\n\t}\n\n\tif (permission.groupPermissionId) {\n\t\tawait Permissions.addRole(permission.groupPermissionId, role);\n\t\tvoid notifyOnPermissionChangedById(permission.groupPermissionId);\n\t}\n\n\tawait Permissions.addRole(permission._id, role);\n\n\tvoid notifyOnPermissionChangedById(permission._id);\n};\n\nexport const removeRoleFromPermissionMethod = async (uid: string, permissionId: string, role: string): Promise<void> => {\n\tconst permission = await Permissions.findOneById(permissionId);\n\n\tif (!permission) {\n\t\tthrow new Meteor.Error('error-permission-not-found', 'Permission not found', {\n\t\t\tmethod: 'authorization:removeRoleFromPermission',\n\t\t});\n\t}\n\n\tif (\n\t\t!(await hasPermissionAsync(uid, 'access-permissions')) ||\n\t\t(permission.level === CONSTANTS.SETTINGS_LEVEL && !(await hasPermissionAsync(uid, 'access-setting-permissions')))\n\t) {\n\t\tthrow new Meteor.Error('error-action-not-allowed', 'Removing permission is not allowed', {\n\t\t\tmethod: 'authorization:removeRoleFromPermission',\n\t\t\taction: 'Removing_permission',\n\t\t});\n\t}\n\n\tif (permission.groupPermissionId) {\n\t\tawait Permissions.removeRole(permission.groupPermissionId, role);\n\t\tvoid notifyOnPermissionChangedById(permission.groupPermissionId);\n\t}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/authorization/permissionRole.ts#L43-L79","documentation":"Thrown when removing a role from a permission whose permissionId resolves to no document in the Permissions collection. Reached via DDP 'authorization:removeRoleFromPermission' or 'POST /api/v1/permissions.removeRole'. Unlike the add path there is no role existence check here, so this error is purely about the permission id.","triggerScenarios":"The permissions screen holds a permission id that a Rocket.Chat upgrade renamed or removed (permission definitions change between versions); a script posts permissions.removeRole with a stale or hardcoded permissionId; mixed-version cluster where nodes hold different permission documents.","commonSituations":"Editing permissions right after an upgrade without a page reload; server downgrades; workspace restores where the Permissions collection drifted from the version's expected permission ids.","solutions":["Reload the permissions list so the client resends current ids, then retry","Verify the permissionId against the live permission list before calling","In mixed-version deployments, finish upgrading all nodes before editing permissions","If automating, fetch permission ids at runtime instead of persisting them"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const known = new Set((await fetchPermissionsList()).map((p) => p._id));\nif (!known.has(permissionId)) {\n  // refetch the permission list / abort instead of calling permissions.removeRole\n}","typeGuard":null,"tryCatchPattern":"try {\n  await call('authorization:removeRoleFromPermission', permissionId, role);\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-permission-not-found') {\n    // reload permissions metadata and retry once with fresh ids\n  } else {\n    throw e;\n  }\n}","preventionTips":["Refetch permission metadata after every server upgrade","Never persist permission ids across releases; re-resolve at runtime","Automate permission changes only against a single, fully upgraded server version"],"tags":["rocket-chat","authorization","permissions","meteor-methods","rest-api"],"backgroundTag":"permission-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}