{"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":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/audit/functions.ts","lineNumber":122,"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":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/lib/audit/functions.ts#L104-L140","documentation":"Thrown by auditGetMessagesMethod (functions.ts:122) when getRoomInfoByAuditParams returns undefined — meaning no room matches the supplied rid/type/users/visitor/agent combination. Meteor.Error code 'Room doesn't exist'. This branch runs for every type except 'u' (user-message audit).","triggerScenarios":"An audit query for a specific rid that does not exist or that carries abacAttributes (excluded by the query); type 'd' with usernames that share no direct room (findDirectRoomContainingAllUsernames returns null); type 'l' with a visitor/agent pair that has no matching LivechatRooms.","commonSituations":"Client passes a deleted room id; a DM query where the listed usernames never had a direct conversation; an omnichannel audit with a visitor/agent pair from different departments; ABAC-protected rooms being filtered out.","solutions":["Validate that the rid exists and is not ABAC-protected before submitting the audit request.","For type 'd', confirm the listed usernames actually share a direct message room.","For type 'l', confirm the visitor/agent pairing has at least one LivechatRooms document.","Treat as user input error — surface 'no such room' to the operator rather than retrying."],"exampleFix":"// before: assume rid is valid\nawait auditGetMessagesMethod(userId, { rid, type: 'c', startDate, endDate });\n\n// after: guard before calling\nconst room = await Rooms.findOneById(rid);\nif (!room || room.abacAttributes) {\n  return notifyCaller('Room not available for audit');\n}\nawait auditGetMessagesMethod(userId, { rid, type: room.t, startDate, endDate });","handlingStrategy":"validation","validationCode":"async function resolveAuditRoom({ rid, type, users, visitor, agent }) {\n  if (rid) { const r = await Rooms.findOne({ _id: rid, abacAttributes: { $exists: false } }); if (!r) return null; }\n  if (type === 'd') return await Rooms.findDirectRoomContainingAllUsernames(users);\n  if (type === 'l') { const rs = await LivechatRooms.findByVisitorIdAndAgentId(visitor, agent).toArray(); return rs.length ? rs : null; }\n  return null;\n}","typeGuard":"const isResolvableType = (t: string): t is 'u' | 'd' | 'l' | 'c' => ['u','d','l','c'].includes(t);","tryCatchPattern":"try { await auditGetMessagesMethod(userId, params); } catch (e) {\n  if (e instanceof Meteor.Error && e.reason === `Room doesn't exist`) {\n    // inform operator no matching room; offer to broaden criteria\n  } else throw e;\n}","preventionTips":["Validate rid existence (and ABAC exclusion) before auditing.","For type 'd', confirm usernames share a DM; for 'l', confirm visitor/agent pairing has rooms."],"tags":["audit","rooms","query","enterprise"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}