RocketChat/Rocket.Chat · error · Error

invalid-room

invalid-room

Error message

invalid-room

What it means

Thrown by GET livechat/transfer.history/:rid when LivechatRooms.findOneById(rid) returns null. The route only projects {_id:1} to confirm existence; it does not validate that the room is an omnichannel room, only that some room with that id exists.

Source

Thrown at apps/meteor/server/api/v1/omnichannel/transfer.ts:16

import { LivechatRooms } from '@rocket.chat/models';

import { API } from '../..';
import { findLivechatTransferHistory } from './lib/transfer';
import { getPaginationItems } from '../../lib/getPaginationItems';

API.v1.addRoute(
	'livechat/transfer.history/:rid',
	{ authRequired: true, permissionsRequired: ['view-livechat-rooms'] },
	{
		async get() {
			const { rid } = this.urlParams;

			const room = await LivechatRooms.findOneById(rid, { projection: { _id: 1 } });
			if (!room) {
				throw new Error('invalid-room');
			}
			const { offset, count } = await getPaginationItems(this.queryParams);
			const { sort } = await this.parseJsonQuery();

			const history = await findLivechatTransferHistory({
				rid,
				pagination: {
					offset,
					count,
					sort,
				},
			});

			return API.v1.success(history);
		},
	},
);

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Confirm the rid exists via a direct db lookup or the rooms REST endpoint before fetching history.
  2. Re-fetch the current rid from the livechat room list rather than a cached value.
  3. Validate the rid format (17-char alphanum in default deployments) before issuing the request.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

const exists = await fetch('/api/v1/v1/rooms.info?roomName=' + encodeURIComponent(name));
if (!exists.ok) throw new Error('refresh rid list');
const rid = (await exists.json()).room._id;

Type guard

null

Try / catch

try {
  await fetch(`/api/v1/v1/livechat/transfer.history/${rid}`);
} catch (e) {
  if (e.error === 'invalid-room') { /* re-fetch rid from livechat rooms, then retry once */ }
}

Prevention

When it happens

Trigger: Caller passes a rid that does not exist in the rocketchat_room collection; a mistyped or truncated id; the room was deleted before the call; the id is a valid object id but for a different collection's document.

Common situations: Frontend cached a stale rid after the room was closed and pruned; URL parameter substitution bug dropping characters; copy/paste of a message id rather than a room id.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/8f3b570a950fd888. Report an issue: GitHub.