RocketChat/Rocket.Chat · error · Error

error-room-does-not-exist

error-room-does-not-exist

Error message

error-room-does-not-exist

What it means

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.

Source

Thrown at apps/meteor/ee/server/api/v1/omnichannel/lib/priorities.ts:70

	const createdResult = await LivechatPriority.updatePriority(_id, data.reset || false, data.name);

	if (!createdResult) {
		logger.error({ msg: 'Error updating priority: unsuccessful result from MongoDB', priorityId: _id, result: createdResult });
		throw Error('error-unable-to-update-priority');
	}

	return createdResult;
}

export const updateRoomPriority = async (
	rid: string,
	user: Required<Pick<IUser, '_id' | 'username' | 'name'>>,
	priorityId: string,
): Promise<void> => {
	const room = await LivechatRooms.findOneById(rid);
	if (!room) {
		throw new Error('error-room-does-not-exist');
	}

	const priority = await LivechatPriority.findOneById(priorityId);
	if (!priority) {
		throw new Error('error-invalid-priority');
	}

	await Promise.all([
		LivechatRooms.setPriorityByRoomId(rid, priority),
		LivechatInquiry.setPriorityForRoom(rid, priority),
		addPriorityChangeHistoryToRoom(room._id, user, priority),
	]);

	void notifyOnRoomChanged({ ...room, priorityId: priority._id, priorityWeight: priority.sortItem }, 'updated');
	void notifyOnLivechatInquiryChangedByRoom(rid, 'updated');
};

export const removePriorityFromRoom = async (rid: string, user: Required<Pick<IUser, '_id' | 'username' | 'name'>>): Promise<void> => {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. 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.
  2. Confirm the rid comes from the same workspace/environment you are calling.
  3. If the room was deleted intentionally, drop it from client state instead of retrying.

Example fix

// before
await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId }); // rid from a stale cache

// after
const info = await api.get('/v1/rooms.info', { params: { roomId: rid } });
if (info?.room?._id) {
  await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });
}
Defensive patterns

Strategy: validation

Validate before calling

const info = await api.get('/v1/rooms.info', { params: { roomId: rid } });
if (!info?.room?._id) throw new Error(`Room ${rid} not found; refusing to set priority`);
await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });

Try / catch

try {
  await api.post(`/v1/livechat/room/${rid}/priority`, { priorityId });
} catch (e) {
  if (e?.response?.data?.errorType === 'error-room-does-not-exist') {
    // remove rid from local state; do not retry
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/2819bc5b0d1aaed7. Report an issue: GitHub.