RocketChat/Rocket.Chat · error · Error

error-invalid-room

Error message

error-invalid-room

What it means

Thrown by runVerifyContactChannel when LivechatRooms.findOneById(roomId) returns null. The room is required both as the source for the channel match and as the IOmnichannelRoom passed into _verifyContactChannel, so a missing room aborts before any transactional work starts.

Source

Thrown at apps/meteor/ee/server/patches/verifyContactChannel.ts:73

		await session.endSession();
	}
}

export const runVerifyContactChannel = async (
	_next: any,
	params: {
		contactId: string;
		field: string;
		value: string;
		visitorId: string;
		roomId: string;
	},
): Promise<ILivechatContact | null> => {
	const { roomId, contactId, visitorId } = params;

	const room = await LivechatRooms.findOneById(roomId);
	if (!room) {
		throw new Error('error-invalid-room');
	}

	const result = await _verifyContactChannel(params, room);

	logger.debug({ msg: 'Finding inquiry', roomId });

	// Note: we are not using the session here since allowing the transactional flow to be used inside the
	//       saveQueueInquiry function would require a lot of changes across the codebase, so if we fail here we
	//       will not be able to rollback the transaction. That is not a big deal since the contact will be properly
	//       merged and the inquiry will be saved in the queue (will need to be taken manually by an agent though).
	const inquiry = await LivechatInquiry.findOneByRoomId(roomId);
	if (!inquiry) {
		// Note: if this happens, something is really wrong with the queue, so we should throw an error to avoid
		//       carrying on a weird state.
		throw new Error('error-invalid-inquiry');
	}

	if (inquiry.status === LivechatInquiryStatus.VERIFYING) {

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Confirm the room exists with LivechatRooms.findOneById(roomId) before invoking verifyContactChannel.
  2. If the room was deleted, drop the verification request and notify the agent.
  3. Make sure the roomId is the omnichannel room _id (not the inquiry id or visitor id).
  4. Re-check you are querying the same Mongo database/workspace.

Example fix

// before
await verifyContactChannel({ contactId, field, value, visitorId, roomId });

// after
const room = await LivechatRooms.findOneById(roomId);
if (!room) throw new Error('Room not found — cannot verify channel');
await verifyContactChannel({ contactId, field, value, visitorId, roomId });
Defensive patterns

Strategy: validation

Validate before calling

async function roomExists(roomId: string): Promise<boolean> {
  const room = await LivechatRooms.findOneById(roomId, { projection: { _id: 1 } });
  return Boolean(room);
}

Try / catch

try {
  await verifyContactChannel(params);
} catch (e) {
  if (e.message === 'error-invalid-room') {
    // drop the verification request and notify the agent
  } else throw e;
}

Prevention

When it happens

Trigger: Calling verifyContactChannel with a roomId that does not correspond to any livechat room document; room was deleted between the queue step and verification; roomId mistyped or from another workspace.

Common situations: Stale roomId in a queued inquiry after the room was closed/deleted; race between room closure and the verification callback; cross-environment id leakage; test calling verifyContactChannel without seeding the room.

Related errors


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