RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-priority
error-invalid-priority
Error message
Invalid priority
What it means
Thrown by the `beforeNewInquiry` omnichannel hook when `extraData.priority` is provided but `LivechatPriority.findOneByIdOrName(prioritySearchTerm)` returns null. The priority referenced for a new inquiry does not exist. It is a `Meteor.Error` with code `error-invalid-priority` and metadata `{ function: 'livechat.beforeInquiry' }`.
Source
Thrown at apps/meteor/ee/server/hooks/omnichannel/beforeNewInquiry.ts:31
}
let sla: IOmnichannelServiceLevelAgreements | null = null;
let priority: ILivechatPriority | null = null;
if (slaSearchTerm) {
sla = await OmnichannelServiceLevelAgreements.findOneByIdOrName(slaSearchTerm, {
projection: { dueTimeInMinutes: 1 },
});
if (!sla) {
throw new Meteor.Error('error-invalid-sla', 'Invalid sla', {
function: 'livechat.beforeInquiry',
});
}
}
if (prioritySearchTerm) {
priority = await LivechatPriority.findOneByIdOrName(prioritySearchTerm, {
projection: { _id: 1, sortItem: 1 },
});
if (!priority) {
throw new Meteor.Error('error-invalid-priority', 'Invalid priority', {
function: 'livechat.beforeInquiry',
});
}
}
const ts = new Date();
const changes: Partial<ILivechatInquiryRecord> = {
ts,
};
if (sla) {
changes.slaId = sla._id;
changes.estimatedWaitingTimeQueue = sla.dueTimeInMinutes;
}
if (priority) {
changes.priorityId = priority._id;
changes.priorityWeight = priority.sortItem;
}
return { ...props, ...changes };
},View on GitHub (pinned to f9d3ec372b)
Solutions
- Verify the priority exists via `LivechatPriority.findOneByIdOrName(term)` before submitting the inquiry.
- Omit `extraData.priority` if no priority is required.
- Re-enable or recreate the priority record if it was disabled in error.
Defensive patterns
Strategy: validation
Validate before calling
import { LivechatPriority } from '../../../../server/models';
async function priorityExists(searchTerm: string): Promise<boolean> {
if (!searchTerm) return true;
return Boolean(await LivechatPriority.findOneByIdOrName(searchTerm, { projection: { _id: 1, sortItem: 1 } }));
} Type guard
function isInvalidPriorityError(e: unknown): boolean {
return e instanceof Meteor.Error && (e as Meteor.Error).error === 'error-invalid-priority';
} Try / catch
try {
await callbacks.run('livechat.beforeInquiry', extraData);
} catch (e) {
if (e instanceof Meteor.Error && e.error === 'error-invalid-priority') {
// correct or omit extraData.priority
}
throw e;
} Prevention
- Validate priority references (id/name) before creating inquiries.
- Omit `extraData.priority` when no priority is needed.
- Re-enable disabled priorities or remove stale references in integrations.
When it happens
Trigger: Creating a livechat inquiry with `extraData.priority` set to an id or name that matches no priority document.
Common situations: Client sends a stale priority id after the priority was removed/disabled; REST API caller passes a priority name that doesn't exist; priority disabled but still referenced by integrations.
Related errors
- error-forwarding-department-target-not-allowed
- error-invalid-sla
- error-invalid-sla
- No inquiry or agent provided
- Provided agent is not online
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/cd01daaed26754d8.
Report an issue: GitHub.