RocketChat/Rocket.Chat · error · Error

error-invalid-inquiry

Error message

error-invalid-inquiry

What it means

Thrown by setSLAToInquiry when no LivechatInquiry is found for the roomId, or when the inquiry's status is not 'queued'. SLA can only be attached to an inquiry that is still queued (not yet taken/processed); once it leaves that state the SLA assignment is rejected. Plain Error, code 'error-invalid-inquiry'.

Source

Thrown at apps/meteor/ee/server/api/v1/omnichannel/lib/inquiries.ts:8

import { LivechatInquiry, Users, OmnichannelServiceLevelAgreements } from '@rocket.chat/models';

import { updateRoomSLA } from './sla';

export async function setSLAToInquiry({ userId, roomId, sla }: { userId: string; roomId: string; sla?: string }): Promise<void> {
	const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } });
	if (!inquiry || inquiry.status !== 'queued') {
		throw new Error('error-invalid-inquiry');
	}

	const slaData = sla && (await OmnichannelServiceLevelAgreements.findOneByIdOrName(sla));
	if (!slaData) {
		throw new Error('error-invalid-sla');
	}

	const user = await Users.findOneById(userId, { projection: { _id: 1, username: 1, name: 1 } });
	if (!user?.username) {
		throw new Error('error-invalid-user');
	}

	await updateRoomSLA(
		roomId,
		{
			_id: user._id,
			name: user.name || '',
			username: user.username,

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Fetch the inquiry and confirm status === 'queued' before calling setSLAToInquiry.
  2. Ensure the SLA is set while the conversation is still in the queue (e.g. via a queue entry hook).
  3. Retry only if the inquiry can be re-queued; otherwise abandon the SLA assignment.
  4. Verify the roomId belongs to a livechat inquiry (not a regular channel).

Example fix

// before: assign SLA blindly
await setSLAToInquiry({ userId, roomId, sla });

// after: confirm queued state
const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } });
if (!inquiry || inquiry.status !== 'queued') {
  throw new ClientError('Room inquiry is not queued; SLA cannot be set.');
}
await setSLAToInquiry({ userId, roomId, sla });
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the inquiry is queued before setting SLA
import { LivechatInquiry } from '@rocket.chat/models';
const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } });
if (!inquiry || inquiry.status !== 'queued') {
  throw new ClientError('Inquiry not queued; cannot set SLA');
}
await setSLAToInquiry({ userId, roomId, sla });

Type guard

function isInquiryQueued(i: { status?: string } | null | undefined): i is { status: 'queued' } {
  return !!i && i.status === 'queued';
}

Try / catch

try {
  await setSLAToInquiry({ userId, roomId, sla });
} catch (e) {
  if (e.message === 'error-invalid-inquiry') {
    // inquiry no longer queued; abandon SLA assignment
    return { ok: false, reason: 'not-queued' };
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling setSLAToInquiry for a roomId whose inquiry was already taken/closed, or that has no inquiry record at all; passing the room ID of a non-omnichannel room; retrying after the inquiry was dispatched.

Common situations: Agent took the chat between the SLA selection and the assignment; SLA set attempted on an already-closed conversation; race between queue dispatch and SLA config; wrong roomId passed.

Related errors


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