{"record":{"id":"040bb9d2c60549c5","repo":"RocketChat/Rocket.Chat","slug":"error-not-allowed-040bb9","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/rooms/getRoomIdByNameOrId.ts","lineNumber":31,"sourceCode":"\t\tgetRoomIdByNameOrId(rid: string): string;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync getRoomIdByNameOrId(rid) {\n\t\tmethodDeprecationLogger.method('getRoomIdByNameOrId', '9.0.0', '/v1/rooms.info');\n\t\tcheck(rid, String);\n\n\t\tif (!Meteor.userId()) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'getRoomIdByNameOrId',\n\t\t\t});\n\t\t}\n\n\t\tconst room = (await Rooms.findOneById(rid)) || (await Rooms.findOneByName(rid));\n\n\t\tif (room == null) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\t\tmethod: 'getRoomIdByNameOrId',\n\t\t\t});\n\t\t}\n\n\t\tif (!(await canAccessRoomAsync(room, (await Meteor.userAsync()) ?? undefined))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\t\tmethod: 'getRoomIdByNameOrId',\n\t\t\t});\n\t\t}\n\n\t\treturn room._id;\n\t},\n});\n","sourceCodeStart":13,"sourceCodeEnd":45,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/getRoomIdByNameOrId.ts#L13-L45","documentation":"getRoomIdByNameOrId failed to resolve its argument: neither Rooms.findOneById(rid) nor Rooms.findOneByName(rid) matched a document, so the method reports 'error-not-allowed'. The input is treated as an id first, then as a room name; no room exists under either interpretation.","triggerScenarios":"Passing a room id or name that was deleted, renamed, or mistyped; passing a channel name that includes the leading '@' or '#' decoration; passing an id belonging to a message, user, or subscription rather than a room.","commonSituations":"Integrations resolving human-entered channel names where the channel was renamed or removed; stale configuration referencing old room names; case-sensitivity or whitespace issues in the stored name.","solutions":["Print the exact value being passed and check it against db.rooms in a server shell (by _id and by name)","Trim the input and strip @/# decorations before sending","If the room was renamed, update the stored reference to the new name or stable _id","Migrate to GET /api/v1/rooms.info which accepts roomName and gives clearer failure semantics"],"exampleFix":"// before - raw user input may be deleted/renamed\nconst id = await Meteor.callAsync('getRoomIdByNameOrId', input);\n\n// after - normalize input and fall back gracefully\nconst clean = input.trim().replace(/^[@#]/, '');\nconst id = await Meteor.callAsync('getRoomIdByNameOrId', clean);","handlingStrategy":"validation","validationCode":"// normalize input and validate against known rooms before resolving\nconst clean = String(raw).trim().replace(/^[@#]/, '');\nif (!clean) throw new Error('empty room reference');\nconst id = await Meteor.callAsync('getRoomIdByNameOrId', clean);","typeGuard":null,"tryCatchPattern":"try {\n  const id = await Meteor.callAsync('getRoomIdByNameOrId', clean);\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-not-allowed') {\n    // no room matched by _id or name - surface a 'room not found' UX\n    notifyRoomNotFound(clean);\n  }\n}","preventionTips":["Store room _ids, not names, in long-lived configuration (names change)","Strip decorations and whitespace from user-entered room references","Verify references after workspace imports/renames"],"tags":["meteor","ddp","rooms","not-found","deprecated"],"backgroundTag":"room-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}