RocketChat/Rocket.Chat · error · Error
error-invalid-inquiry
error-invalid-inquiry
Error message
error-invalid-inquiry
What it means
setSLAToInquiry requires the room's livechat inquiry to exist and have status 'queued'. A missing inquiry (roomId is not an omnichannel room, or no inquiry was created) or any non-queued status (taken, closed) throws 'error-invalid-inquiry' before the SLA is even resolved.
Solutions
- Re-check the inquiry is still queued immediately before the call (inquiry/queue lookup)
- Treat taken/closed as a benign race: skip the room instead of retrying the same call
- Set SLA at routing time (department-level SLA) rather than post-hoc on live inquiries
Defensive patterns
Strategy: try-catch
Validate before calling
import { LivechatInquiry } from '@rocket.chat/models';
const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } });
if (!inquiry || inquiry.status !== 'queued') {
throw new Error(`room ${roomId} has no queued inquiry - skip SLA assignment`);
}
await setSLAToInquiry({ userId, roomId, sla }); Try / catch
try {
await setSLAToInquiry({ userId, roomId, sla });
} catch (error) {
if (error instanceof Error && error.message === 'error-invalid-inquiry') {
// queue state raced us (taken/closed): benign, do not retry the same room
logger.info('inquiry no longer queued', { roomId });
return;
}
throw error;
} Prevention
- Check inquiry status immediately before the call, but still handle the race
- Prefer department/routing-time SLA configuration over live inquiry mutation
- Confirm roomId is an omnichannel room before SLA operations
When it happens
Trigger: Setting SLA on a room whose inquiry was already taken by an agent or whose conversation is closed; roomId of a non-omnichannel room; racing another agent accepting the queued chat between check and call.
Common situations: Automation assigning SLA at the same moment the chat gets picked up; retrying after the queue moved on; wrong room id passed by the integration.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/7cd9503c9cbf6f1d.
Report an issue: GitHub.
Appendix: 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 b2c16d5842)