RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-priority
error-invalid-priority
Error message
Invalid priority
What it means
Thrown by the 'livechat.beforeNewInquiry' hook when extraData.priority is set but LivechatPriority.findOneByIdOrName cannot find a matching priority record by id or name. The priority drives queue sortItem ordering on the inquiry, so an unresolvable reference aborts inquiry creation rather than silently defaulting.
Solutions
- List current priorities (Administration > Omnichannel > Priorities or the priorities API) and send a valid _id or exact name
- Recreate the missing priority or update the calling integration
- Drop the priority field if the inquiry should use the default queue ordering
Example fix
// before: assuming the priority exists
await createInquiry({ ...data, priority: 'high-prio' });
// after: validate the reference beforehand
const priority = await LivechatPriority.findOneByIdOrName('high-prio', {
projection: { _id: 1, sortItem: 1 },
});
if (!priority) throw new Error('Unknown priority: high-prio');
await createInquiry({ ...data, priority: 'high-prio' }); Defensive patterns
Strategy: validation
Validate before calling
const priorityExists = async (term: string): Promise<boolean> =>
Boolean(await LivechatPriority.findOneByIdOrName(term, { projection: { _id: 1 } })); Try / catch
try {
await createInquiry({ ...data, priority: term });
} catch (err: any) {
if (err?.error === 'error-invalid-priority') {
// fetch current priorities and correct the reference
}
throw err;
} Prevention
- Seed environments with the same priority ids/names used by clients
- Validate priority names on the client against the priorities API before submit
- Avoid localized display names as API identifiers
When it happens
Trigger: Creating a livechat inquiry with a priority id/name that was deleted, renamed, or typo'd; integrations replaying cached priority identifiers after an environment refresh.
Common situations: Priorities re-seeded between environments (dev -> prod) with new ids; clients hard-coding priority names like 'highest' that were localized or renamed.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/cd01daaed26754d8.
Report an issue: GitHub.
Appendix: 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 b2c16d5842)