RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-sla
error-invalid-sla
Error message
Invalid sla
What it means
Thrown by the `beforeNewInquiry` omnichannel hook (MEDIUM priority, `livechat.beforeInquiry`) when `extraData.sla` is provided but `OmnichannelServiceLevelAgreements.findOneByIdOrName(slaSearchTerm)` returns null. The SLA referenced for a new inquiry does not exist. It is a `Meteor.Error` with code `error-invalid-sla` and metadata `{ function: 'livechat.beforeInquiry' }`.
Source
Thrown at apps/meteor/ee/server/hooks/omnichannel/beforeNewInquiry.ts:21
import { Meteor } from 'meteor/meteor';
import { callbacks } from '../../../../server/lib/callbacks';
callbacks.add(
'livechat.beforeInquiry',
async (extraData) => {
const { sla: slaSearchTerm, priority: prioritySearchTerm, ...props } = extraData;
if (!slaSearchTerm && !prioritySearchTerm) {
return extraData;
}
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,
};View on GitHub (pinned to f9d3ec372b)
Solutions
- Verify the SLA exists via `OmnichannelServiceLevelAgreements.findOneByIdOrName(term)` before submitting the inquiry.
- Omit `extraData.sla` if no SLA is required.
- Re-create or correct the SLA record if it was deleted in error.
Defensive patterns
Strategy: validation
Validate before calling
import { OmnichannelServiceLevelAgreements } from '../../../../server/models';
async function slaExists(searchTerm: string): Promise<boolean> {
if (!searchTerm) return true;
return Boolean(await OmnichannelServiceLevelAgreements.findOneByIdOrName(searchTerm, { projection: { dueTimeInMinutes: 1 } }));
} Type guard
function isInvalidSlaError(e: unknown): boolean {
return e instanceof Meteor.Error && (e as Meteor.Error).error === 'error-invalid-sla';
} Try / catch
try {
await callbacks.run('livechat.beforeInquiry', extraData);
} catch (e) {
if (e instanceof Meteor.Error && e.error === 'error-invalid-sla') {
// correct or omit extraData.sla
}
throw e;
} Prevention
- Validate SLA references (id/name) before creating inquiries.
- Omit `extraData.sla` when no SLA is needed.
- Keep client-side SLA lists in sync with server records.
When it happens
Trigger: Creating a livechat inquiry with `extraData.sla` set to an id or name that matches no SLA document (deleted, never existed, typo, or wrong casing).
Common situations: Client sends a stale SLA id after the SLA was removed; REST API caller passes an SLA name that doesn't exist; SLA was renamed and the old name is still referenced.
Related errors
- error-invalid-sla
- error-forwarding-department-target-not-allowed
- error-invalid-priority
- error-invalid-sla
- No inquiry or agent provided
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/c6cd421a6fdee94d.
Report an issue: GitHub.