{"record":{"id":"6d8ad7f8916935ab","repo":"RocketChat/Rocket.Chat","slug":"error-not-allowed-6d8ad7","errorCode":"error-not-allowed","errorMessage":"Not allowed","messagePattern":"Not allowed","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts","lineNumber":10,"sourceCode":"import { CannedResponse } from '@rocket.chat/models';\nimport { check } from 'meteor/check';\nimport { Meteor } from 'meteor/meteor';\n\nimport { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission';\nimport notifications from '../../../server/lib/notifications/core/lib/Notifications';\n\nexport const removeCannedResponse = async (uid: string, _id: string): Promise<void> => {\n\tif (!(await hasPermissionAsync(uid, 'remove-canned-responses'))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'removeCannedResponse',\n\t\t});\n\t}\n\n\tcheck(_id, String);\n\n\tconst cannedResponse = await CannedResponse.findOneById(_id);\n\tif (!cannedResponse) {\n\t\tthrow new Meteor.Error('error-canned-response-not-found', 'Canned Response not found', {\n\t\t\tmethod: 'removeCannedResponse',\n\t\t});\n\t}\n\n\tnotifications.streamCannedResponses.emit('canned-responses', { type: 'removed', _id });\n\n\tawait CannedResponse.removeById(_id);\n};\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts#L1-L28","documentation":"Thrown by removeCannedResponse when hasPermissionAsync(uid, 'remove-canned-responses') returns false. The user lacks the permission to delete canned responses. Code is 'error-not-allowed'.","triggerScenarios":"Calling removeCannedResponse (the canned-response delete method) with a uid whose roles do not grant 'remove-canned-responses'.","commonSituations":"Agent or livechat-manager role without the remove permission assigned; permission role was edited and the toggle dropped; new install where the role has not been configured.","solutions":["Grant 'remove-canned-responses' to the user's role in Administration > Permissions.","If the user should only manage their own responses, restrict the UI to delete-by-owner rather than removing this permission.","Confirm the uid passed in is the logged-in user, not a stale id."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!(await hasPermissionAsync(uid, 'remove-canned-responses'))) {\n  throw new Error('You do not have permission to remove canned responses');\n}\nawait removeCannedResponse(uid, _id);","typeGuard":null,"tryCatchPattern":"try {\n  await removeCannedResponse(uid, _id);\n} catch (e) {\n  if (isMeteorError(e, 'error-not-allowed')) {\n    notifyUser('You lack the remove-canned-responses permission.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Grant 'remove-canned-responses' to the appropriate role.","Hide the delete control for users without the permission.","Pass the acting user's uid, not a cached value."],"tags":["canned-responses","authorization","permissions"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}