{"record":{"id":"fd7375c0826f1c3b","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-fd7375","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/auth/removeRoleFromPermission.ts","lineNumber":19,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Meteor } from 'meteor/meteor';\n\nimport { removeRoleFromPermissionMethod } from '../../lib/authorization/permissionRole';\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'authorization:removeRoleFromPermission'(permissionId: string, role: string): void;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync 'authorization:removeRoleFromPermission'(permissionId, role) {\n\t\tmethodDeprecationLogger.method('authorization:removeRoleFromPermission', '9.0.0', '/v1/permissions.removeRole');\n\t\tconst uid = Meteor.userId();\n\t\tif (!uid) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'authorization:removeRoleFromPermission' });\n\t\t}\n\t\tawait removeRoleFromPermissionMethod(uid, permissionId, role);\n\t},\n});\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/auth/removeRoleFromPermission.ts#L1-L24","documentation":"The deprecated 'authorization:removeRoleFromPermission' method throws 'error-invalid-user' when Meteor.userId() returns null, i.e. the DDP connection is not authenticated. The permission-role change requires an identified admin caller. Deprecated since 9.0.0 in favor of /v1/permissions.removeRole.","triggerScenarios":"Calling the method while logged out or with an expired resume token, e.g. from a stale admin permissions page or an anonymous script.","commonSituations":"Session invalidated after a server restart or concurrent login; automation invoking the method without login.","solutions":["Log in with a valid session before calling 'authorization:removeRoleFromPermission'","Migrate to /v1/permissions.removeRole with an authenticated request","Handle session expiry centrally (re-login, retry once)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const uid = Meteor.userId();\nif (!uid) {\n  // re-login before modifying permission-role mappings\n}\nawait Meteor.callAsync('authorization:removeRoleFromPermission', permissionId, role);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('authorization:removeRoleFromPermission', permissionId, role);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-user') {\n    // session expired: re-login, then retry\n  }\n}","preventionTips":["Check Meteor.userId() before permission-management methods","Migrate to /v1/permissions.removeRole with authenticated REST calls"],"tags":["authentication","authorization","permissions","meteor-methods","deprecated"],"backgroundTag":"not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}