{"record":{"id":"0f925c52a83eb31c","repo":"RocketChat/Rocket.Chat","slug":"error-not-authorized-0f925c","errorCode":"error-not-authorized","errorMessage":"Not authorized","messagePattern":"Not authorized","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/slashcommands/unarchiveroom/server.ts","lineNumber":55,"sourceCode":"\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'archiveRoom' });\n\t\t}\n\n\t\tif (!room) {\n\t\t\tvoid api.broadcast('notify.ephemeralMessage', userId, message.rid, {\n\t\t\t\tmsg: i18n.t('Channel_doesnt_exist', {\n\t\t\t\t\tchannelName: channel,\n\t\t\t\t\tlng: settings.get('Language') || 'en',\n\t\t\t\t}),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.ARCHIVE, userId))) {\n\t\t\tthrow new Meteor.Error('error-room-type-not-unarchivable', `Room type: ${room.t} can not be unarchived`);\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(userId, 'unarchive-room', room._id))) {\n\t\t\tthrow new Meteor.Error('error-not-authorized', 'Not authorized');\n\t\t}\n\n\t\tif (!room.archived) {\n\t\t\tvoid api.broadcast('notify.ephemeralMessage', userId, message.rid, {\n\t\t\t\tmsg: i18n.t('Channel_already_Unarchived', {\n\t\t\t\t\tchannelName: channel,\n\t\t\t\t\tlng: settings.get('Language') || 'en',\n\t\t\t\t}),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait unarchiveRoom(room._id, user);\n\n\t\tvoid api.broadcast('notify.ephemeralMessage', userId, message.rid, {\n\t\t\tmsg: i18n.t('Channel_Unarchived', {\n\t\t\t\tchannelName: channel,\n\t\t\t\tlng: settings.get('Language') || 'en',","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/slashcommands/unarchiveroom/server.ts#L37-L73","documentation":"Permission gate in /unarchiveroom: after the room type allows the ARCHIVE action, hasPermissionAsync(userId, 'unarchive-room', room._id) is evaluated (role permission, optionally scoped to the room). If the user lacks the 'unarchive-room' permission the command throws 'error-not-authorized'. Unlike the earlier user-facing branches (which send ephemeral messages), this and the room-type check are hard errors.","triggerScenarios":"A regular member or non-admin user runs /unarchive #channel without holding a role that includes 'unarchive-room' for that room (global or room-scoped).","commonSituations":"Default role setups where only admin/moderator has unarchive-room; users with room-scoped roles that grant archive but not unarchive; permission removed by an admin policy change.","solutions":["Grant the user (or their role) the 'unarchive-room' permission in Administration > Permissions, globally or scoped to the room/channel.","Have an admin or moderator with the permission perform the unarchive.","Before sending the command, check hasPermission('unarchive-room', roomId) client-side and hide/disable the action."],"exampleFix":"// before\nif (!(await hasPermissionAsync(userId, 'unarchive-room', room._id))) {\n  throw new Meteor.Error('error-not-authorized', 'Not authorized');\n}\n\n// client-side pre-check to avoid the error\nconst canUnarchive = useHasPermission('unarchive-room', rid);\n// render the /unarchive entry point only when canUnarchive is true","handlingStrategy":"validation","validationCode":"// Client-side, before enabling the action\nconst canUnarchive = useHasPermission('unarchive-room', rid);\nif (!canUnarchive) { /* hide/disable the unarchive control */ }","typeGuard":null,"tryCatchPattern":"try { await Meteor.callAsync('slashCommand', { command: 'unarchiveroom', ... }); } catch (e) { if (isMeteorError(e, 'error-not-authorized')) { /* request unarchive-room permission or escalate to admin */ return; } throw e; }","preventionTips":["Grant 'unarchive-room' to the roles that need it, scoped per room where possible.","Check permission before sending the command.","Route unarchive requests through admins when role permissions are locked down."],"tags":["rocket-chat","permissions","authorization","slash-command"],"backgroundTag":"permission-denied","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}