{"record":{"id":"ff4b489ba9ff1396","repo":"RocketChat/Rocket.Chat","slug":"error-not-allowed-ff4b48","errorCode":"error-not-allowed","errorMessage":"Not allowed","messagePattern":"Not allowed","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/translateMessage.ts","lineNumber":33,"sourceCode":"}\n\nMeteor.methods<ServerMethods>({\n\tasync 'autoTranslate.translateMessage'(message, targetLanguage) {\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'autoTranslate.translateMessage',\n\t\t\t});\n\t\t}\n\t\tcheck(message?._id, String);\n\t\tcheck(targetLanguage, String);\n\t\tconst msg = await Messages.findOneById(message._id);\n\t\tif (!msg) {\n\t\t\tthrow new Meteor.Error('error-message-not-found', 'Message not found');\n\t\t}\n\t\tconst room = await Rooms.findOneById(msg.rid);\n\t\tif (!room || !(await canAccessRoomAsync(room, { _id: userId }))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed');\n\t\t}\n\t\treturn translateMessage(targetLanguage, msg);\n\t},\n});\n","sourceCodeStart":15,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/translateMessage.ts#L15-L38","documentation":"Thrown by 'autoTranslate.translateMessage' when Rooms.findOneById(msg.rid) returns nothing (message without a live room) or when canAccessRoomAsync(room, { _id: userId }) denies the caller. The second, far more common path is an authorization failure: the user is not a member of, and cannot otherwise access, the room the message belongs to.","triggerScenarios":"Translating a message in a room the user was removed from while it was still rendered; a message from a private room surfaced through a quote/thread the user cannot access; a deleted room still referenced by cached messages.","commonSituations":"Removed-from-channel races in busy clients; DM history still rendered after the conversation closed; rooms switched from public to private by admins.","solutions":["Before translating, verify the user still has access to the message's room (active subscription or public room).","Client-side, drop or lock messages whose room subscription was removed.","If access is denied unexpectedly, audit the room type and the user's roles against canAccessRoom rules (e.g. private room without membership)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before offering translate, confirm the user still has a subscription for the room\nconst sub = await RocketChat.models.Subscriptions.findOne({ rid: message.rid });\nif (!sub && !roomIsPubliclyReadable(message.rid)) {\n\t// hide translate action - server will reject with error-not-allowed\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait Meteor.callAsync('autoTranslate.translateMessage', { _id: message._id }, lang);\n} catch (e: any) {\n\tif (e?.error === 'error-not-allowed') {\n\t\t// user lost access to msg.rid: purge cached messages for that room\n\t}\n}","preventionTips":["Prune cached room messages when the subscription-remove event arrives.","Do not surface translate actions on quoted messages from rooms the user cannot access.","Audit room access after permission model changes if denials appear unexpected."],"tags":["meteor-methods","auto-translate","authorization","rooms"],"backgroundTag":"permission-denied","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}