RocketChat/Rocket.Chat · error · Meteor.Error

error-canned-response-not-found

error-canned-response-not-found

Error message

Canned Response not found

What it means

Thrown by removeCannedResponse (removeCannedResponse.ts:19) after the permission check: CannedResponse.findOneById(_id) returns null, so there is nothing to remove. The id passed does not match any canned response document.

Solutions

  1. Refresh the canned response list and retry with a current id
  2. Treat error-canned-response-not-found as success in idempotent delete flows (goal already achieved)
  3. Verify the id originates from a fresh CannedResponse.find query

Example fix

// before
await removeCannedResponse(uid, _id);

// after
const existing = await CannedResponse.findOneById(_id, { projection: { _id: 1 } });
if (!existing) {
	return; // already removed — treat as deleted
}
await removeCannedResponse(uid, _id);
Defensive patterns

Strategy: validation

Validate before calling

const existing = await CannedResponse.findOneById(_id, { projection: { _id: 1 } });
if (!existing) {
	// already removed or unknown id — treat as deleted
	return;
}
await removeCannedResponse(uid, _id);

Try / catch

try {
	await removeCannedResponse(uid, _id);
} catch (e) {
	if (e instanceof Meteor.Error && e.error === 'error-canned-response-not-found') {
		// idempotent delete: already gone — refresh the list and move on
		return;
	}
	throw e;
}

Prevention

When it happens

Trigger: Deleting a canned response that was already deleted by another user/session, or passing a wrong/truncated _id (check(_id, String) only enforces the type).

Common situations: Stale list in another agent's UI after concurrent deletion; id mangled by client code; canned responses wiped by re-import or workspace copy where ids diverged.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/bf7d95932ffecbde. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/ee/server/meteor-methods/removeCannedResponse.ts:19

import { CannedResponse } from '@rocket.chat/models';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

import { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission';
import notifications from '../../../server/lib/notifications/core/lib/Notifications';

export const removeCannedResponse = async (uid: string, _id: string): Promise<void> => {
	if (!(await hasPermissionAsync(uid, 'remove-canned-responses'))) {
		throw new Meteor.Error('error-not-allowed', 'Not allowed', {
			method: 'removeCannedResponse',
		});
	}

	check(_id, String);

	const cannedResponse = await CannedResponse.findOneById(_id);
	if (!cannedResponse) {
		throw new Meteor.Error('error-canned-response-not-found', 'Canned Response not found', {
			method: 'removeCannedResponse',
		});
	}

	notifications.streamCannedResponses.emit('canned-responses', { type: 'removed', _id });

	await CannedResponse.removeById(_id);
};

View on GitHub (pinned to b2c16d5842)