{"record":{"id":"cbaed3c6031e6edd","repo":"RocketChat/Rocket.Chat","slug":"room-doesn-t-exist","errorCode":"Room doesn't exist","errorMessage":"Room doesn't exist","messagePattern":"Room doesn't exist","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/audit/functions.ts","lineNumber":121,"sourceCode":"\t\tconst usersId = await getUsersIdFromUserName(usernames);\n\t\tquery['u._id'] = { $in: usersId };\n\n\t\tconst abacRooms = await Rooms.findAllPrivateRoomsWithAbacAttributes({ projection: { _id: 1 } })\n\t\t\t.map((doc) => doc._id)\n\t\t\t.toArray();\n\n\t\tquery.rid = { $nin: abacRooms };\n\t} else {\n\t\tconst roomInfo = await getRoomInfoByAuditParams({\n\t\t\ttype,\n\t\t\troomId: rid ?? '',\n\t\t\tusers: usernames,\n\t\t\tvisitor: visitor ?? '',\n\t\t\tagent: agent ?? '',\n\t\t\tuserId: user._id,\n\t\t});\n\t\tif (!roomInfo) {\n\t\t\tthrow new Meteor.Error(`Room doesn't exist`);\n\t\t}\n\n\t\trids = roomInfo.rids;\n\t\tname = roomInfo.name;\n\t\tquery.rid = { $in: rids };\n\t}\n\n\tif (msg) {\n\t\tconst regex = new RegExp(escapeRegExp(msg).trim(), 'i');\n\t\tquery.msg = regex;\n\t}\n\n\tconst messages = await Messages.find(query).toArray();\n\n\tawait AuditLog.insertOne(\n\t\t{\n\t\t\tts: new Date(),\n\t\t\tresults: messages.length,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/ee/server/lib/audit/functions.ts#L103-L139","documentation":"Meteor.Error 'Room doesn't exist' thrown by auditGetMessagesMethod when type !== 'u' and getRoomInfoByAuditParams returns nothing — no room matches the combination of type, roomId, usernames, visitor, agent and the auditor's context. The audit search needs at least one concrete room id set before querying messages, so unmatched filters abort.","triggerScenarios":"Auditing by room type/users/visitor/agent where the referenced room was deleted or the usernames/visitor id don't correspond to any room members; passing a rid that no longer exists; typos in usernames or stale visitor ids.","commonSituations":"Auditing retention-purged rooms; visitor/agent ids copied from another environment; searching direct messages between users where one username changed.","solutions":["Re-check the filter values (exact usernames, rid, visitor/agent ids) against current data","Search by the current room members' usernames if handles were renamed","If the room was deleted, audit from retained message exports rather than the live room lookup"],"exampleFix":"// before: auditing with possibly stale identifiers\nMeteor.call('auditMessages', { type: 'd', users: ['alice', 'bob'], startDate, endDate });\n\n// after: confirm the room resolvable first (user type path needs no room)\nconst roomInfo = await getRoomInfoByAuditParams({ type: 'd', roomId: '', users: ['alice', 'bob'], visitor: '', agent: '', userId: auditorId });\nif (!roomInfo) throw new Error('No room matches those audit filters');\nMeteor.call('auditMessages', { type: 'd', users: ['alice', 'bob'], startDate, endDate });","handlingStrategy":"validation","validationCode":"const auditFiltersMatchRoom = async (params: {\n  type: string; rid?: string; users: string[]; visitor?: string; agent?: string; userId: string;\n}): Promise<boolean> =>\n  Boolean(await getRoomInfoByAuditParams({\n    type: params.type,\n    roomId: params.rid ?? '',\n    users: params.users,\n    visitor: params.visitor ?? '',\n    agent: params.agent ?? '',\n    userId: params.userId,\n  }));","typeGuard":null,"tryCatchPattern":"try {\n  const messages = await auditGetMessagesMethod(userId, params);\n} catch (err: any) {\n  if (err?.error === \"Room doesn't exist\" || err?.reason === \"Room doesn't exist\") {\n    // verify usernames/rid/visitor ids; renamed users and deleted rooms cause this\n  }\n  throw err;\n}","preventionTips":["Resolve current usernames via the user API before auditing DMs","Prefer auditing by concrete rid where possible","For deleted rooms, rely on exported/retained messages instead of live lookups"],"tags":["audit","room-not-found","search-filters","enterprise"],"backgroundTag":"room-not-found","analyzedSha":"2a7de457074cbb4d4373fbd9a4e5bea292c9c764","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}