RocketChat/Rocket.Chat · error

error-transferring-inquiry-no-department

error-transferring-inquiry-no-department

Error message

error-transferring-inquiry-no-department

What it means

Thrown by the department-forward path when transferData.departmentId is falsy - the required target department was not supplied. It fires before any database lookup, making it pure argument validation.

Source

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

	const { _id: rid, servedBy: oldServedBy, departmentId: oldDepartmentId } = room;
	let agent = null;

	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'),
			{},

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Provide a valid departmentId in transferData
  2. Validate the payload against the endpoint schema before submitting
  3. If no department is intended, use the agent forward path with userId instead

Example fix

// before
await forwardRoomToDepartment(room, { clientAction: 'forward' }, guest);

// after
const { departmentId } = transferData;
if (!departmentId) throw new Error('error-transferring-inquiry-no-department');
await forwardRoomToDepartment(room, { ...transferData, departmentId }, guest);
Defensive patterns

Strategy: validation

Validate before calling

const isNonEmptyId = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
if (!isNonEmptyId(transferData.departmentId)) {
  throw new Error('error-transferring-inquiry-no-department');
}
await forwardRoomToDepartment(room, transferData, guest);

Type guard

const isNonEmptyId = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;

Try / catch

try {
  await forwardRoomToDepartment(room, transferData, guest);
} catch (err) {
  if (err instanceof Error && err.message === 'error-transferring-inquiry-no-department') {
    // payload lost departmentId - require it in the form and resubmit
  } else throw err;
}

Prevention

When it happens

Trigger: REST livechat/room.forward payload missing departmentId; the frontend sends userId only but the call routes into the department-forward branch; department select cleared so an empty string is submitted.

Common situations: Form validation gaps; API consumers assuming departmentId is optional; department deleted client-side before submit.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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