{"record":{"id":"2819bc5b0d1aaed7","repo":"RocketChat/Rocket.Chat","slug":"error-room-does-not-exist","errorCode":"error-room-does-not-exist","errorMessage":"error-room-does-not-exist","messagePattern":"error-room-does-not-exist","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/lib/priorities.ts","lineNumber":70,"sourceCode":"\n\tconst createdResult = await LivechatPriority.updatePriority(_id, data.reset || false, data.name);\n\n\tif (!createdResult) {\n\t\tlogger.error({ msg: 'Error updating priority: unsuccessful result from MongoDB', priorityId: _id, result: createdResult });\n\t\tthrow Error('error-unable-to-update-priority');\n\t}\n\n\treturn createdResult;\n}\n\nexport const updateRoomPriority = async (\n\trid: string,\n\tuser: Required<Pick<IUser, '_id' | 'username' | 'name'>>,\n\tpriorityId: string,\n): Promise<void> => {\n\tconst room = await LivechatRooms.findOneById(rid);\n\tif (!room) {\n\t\tthrow new Error('error-room-does-not-exist');\n\t}\n\n\tconst priority = await LivechatPriority.findOneById(priorityId);\n\tif (!priority) {\n\t\tthrow new Error('error-invalid-priority');\n\t}\n\n\tawait Promise.all([\n\t\tLivechatRooms.setPriorityByRoomId(rid, priority),\n\t\tLivechatInquiry.setPriorityForRoom(rid, priority),\n\t\taddPriorityChangeHistoryToRoom(room._id, user, priority),\n\t]);\n\n\tvoid notifyOnRoomChanged({ ...room, priorityId: priority._id, priorityWeight: priority.sortItem }, 'updated');\n\tvoid notifyOnLivechatInquiryChangedByRoom(rid, 'updated');\n};\n\nexport const removePriorityFromRoom = async (rid: string, user: Required<Pick<IUser, '_id' | 'username' | 'name'>>): Promise<void> => {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/api/v1/omnichannel/lib/priorities.ts#L52-L88","documentation":"updateRoomPriority (reached via POST livechat/room/:rid/priority) first loads the room with LivechatRooms.findOneById(rid); when no room document matches, it throws error-room-does-not-exist before the priority is even looked up. This guards the room update, the paired LivechatInquiry priority update, and the priority-change history from running against an unknown room.","triggerScenarios":"POST /api/v1/livechat/room/<rid>/priority with a rid that is not the _id of an existing room: typo or truncated id, an id copied from another workspace/environment, or a room deleted between your list call and the priority call.","commonSituations":"Passing a subscription id, visitor id, or priority id where the room id belongs; mixing staging and production ids in configuration; automation acting on stale cached rids after rooms were closed or purged.","solutions":["Fetch the room fresh (e.g. GET /api/v1/rooms.info?roomId=... or the agent's livechat rooms list) and use the exact _id it returns.","Confirm the rid comes from the same workspace/environment you are calling.","If the room was deleted intentionally, drop it from client state instead of retrying."],"exampleFix":"// before\nawait api.post(`/v1/livechat/room/${rid}/priority`, { priorityId }); // rid from a stale cache\n\n// after\nconst info = await api.get('/v1/rooms.info', { params: { roomId: rid } });\nif (info?.room?._id) {\n  await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });\n}","handlingStrategy":"validation","validationCode":"const info = await api.get('/v1/rooms.info', { params: { roomId: rid } });\nif (!info?.room?._id) throw new Error(`Room ${rid} not found; refusing to set priority`);\nawait api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });\n} catch (e) {\n  if (e?.response?.data?.errorType === 'error-room-does-not-exist') {\n    // remove rid from local state; do not retry\n  } else throw e;\n}","preventionTips":["Always read the room id from the same environment you call.","Re-verify room existence before acting on ids from caches or queues.","Keep room ids and other entity ids in separately named fields to avoid mix-ups."],"tags":["omnichannel","livechat","room","not-found","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}