RocketChat/Rocket.Chat · warning

error-forwarding-chat-same-department

error-forwarding-chat-same-department

Error message

error-forwarding-chat-same-department

What it means

forwardRoomToDepartment rejects transfers whose target departmentId equals the room's current oldDepartmentId - forwarding a chat to the department that already owns it is a no-op. It fires after the presence check, so a non-empty but identical ID triggers it.

Source

Thrown at apps/meteor/server/lib/omnichannel/Helper.ts:654

	const inquiry = await LivechatInquiry.findOneByRoomId(rid, {});
	if (!inquiry) {
		logger.debug({
			msg: 'Cannot forward room. No inquiries found',
			roomId: room._id,
		});
		throw new Error('error-transferring-inquiry');
	}

	const { departmentId } = transferData;
	if (!departmentId) {
		logger.debug({
			msg: 'Cannot forward room. No departmentId provided',
			roomId: room._id,
		});
		throw new Error('error-transferring-inquiry-no-department');
	}
	if (oldDepartmentId === departmentId) {
		throw new Error('error-forwarding-chat-same-department');
	}

	const { userId: agentId, clientAction } = transferData;
	if (agentId) {
		logger.debug({
			msg: 'Forwarding room to department and user',
			roomId: room._id,
			departmentId,
			agentId,
		});
		const user = await Users.findOneOnlineAgentById(
			agentId,
			settings.get<boolean>('Livechat_enabled_when_agent_idle'),
			settings.get<boolean>('Livechat_accept_chats_with_no_agents'),
			{},
		);
		if (!user) {
			throw new Error('error-user-is-offline');

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Pick a different department as the forward target
  2. UI: exclude the room's current department from the target list or warn before submit
  3. To force re-queueing within the same department, use the queue/return flow instead of forward

Example fix

// before
await forwardRoomToDepartment(room, { departmentId: room.departmentId }, guest);

// after
if (room.departmentId === targetDeptId) {
  throw new Error('error-forwarding-chat-same-department');
}
await forwardRoomToDepartment(room, { departmentId: targetDeptId }, guest);
Defensive patterns

Strategy: validation

Validate before calling

if (room.departmentId === transferData.departmentId) {
  // same-department forward is a no-op; block or warn in the UI
  throw new Error('error-forwarding-chat-same-department');
}

Try / catch

try {
  await forwardRoomToDepartment(room, transferData, guest);
} catch (err) {
  if (err instanceof Error && err.message === 'error-forwarding-chat-same-department') {
    // benign: prompt for a different department
  } else throw err;
}

Prevention

When it happens

Trigger: Transfer dialog submitted with the current department selected; automation copying room.departmentId into transferData; supervisor re-forwarding to the same department to 'reset' the chat.

Common situations: Default department selection in the UI being the current one; departments with only one viable option; scripts that echo state back into the request.

Related errors


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