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 when CannedResponse.findOneById(_id) returns null. The canned response id supplied does not match any document, so there is nothing to delete. Code is 'error-canned-response-not-found'.

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 f9d3ec372b)

Solutions

  1. Refresh the canned-response list after a delete and remove the row optimistically or on confirmation.
  2. Treat 'not found' as success for idempotent delete UX (the resource is gone either way).
  3. Validate the id exists before showing the delete confirmation.

Example fix

// before
await removeCannedResponse(uid, _id);

// after
const existing = await CannedResponse.findOneById(_id);
if (!existing) return { alreadyDeleted: true };
await removeCannedResponse(uid, _id);
Defensive patterns

Strategy: try-catch

Validate before calling

const existing = await CannedResponse.findOneById(_id);
if (!existing) return { alreadyDeleted: true };
await removeCannedResponse(uid, _id);

Try / catch

try {
  await removeCannedResponse(uid, _id);
} catch (e) {
  if (isMeteorError(e, 'error-canned-response-not-found')) return;
  throw e;
}

Prevention

When it happens

Trigger: Calling removeCannedResponse with an _id that was already deleted, never existed, or is mistyped; concurrent delete by another user.

Common situations: Stale list in the UI after a delete; duplicate delete clicks; id copied/truncated incorrectly.

Related errors


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