RocketChat/Rocket.Chat · error · Error

error-invalid-actionlink

Error message

error-invalid-actionlink

What it means

actionLinks.run() throws error-invalid-actionlink when no entry in message.actionLinks has a method_id equal to the clicked actionMethodId (message.actionLinks?.find(...) returns undefined). Action links are attached to messages by the server (Apps Engine apps, external integrations) and each button carries a method_id that must be present in the message payload for the client to resolve it.

Solutions

  1. Log message.actionLinks for the clicked message and confirm the method_id you pass actually exists in the array.
  2. Re-fetch or refresh the message (e.g. via /v1/chat.getMessage) before running the link so the payload is current.
  3. If you develop an app, keep method_id values stable across message updates to avoid stale-button clicks.

Example fix

// before
actionLinks.run(message, methodId);

// after
if (message.actionLinks?.some((a) => a.method_id === methodId)) {
  actionLinks.run(message, methodId);
}
Defensive patterns

Strategy: validation

Validate before calling

const link = message.actionLinks?.find((a) => a.method_id === methodId);
if (!link) return; // nothing to run
actionLinks.run(message, methodId);

Type guard

const hasActionLink = (message: IMessage, methodId: string): boolean =>
  Boolean(message.actionLinks?.some((a) => a.method_id === methodId));

Try / catch

try {
  actionLinks.run(message, methodId);
} catch (e) {
  if (e instanceof Error && e.message === 'error-invalid-actionlink') {
    // stale message: refresh it before retrying
    await refreshMessage(message._id);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Clicking an action-link button whose method_id argument does not match any entry in message.actionLinks — e.g. the rendered message is stale (actionLinks were changed server-side after render), the method_id was renamed, or custom code calls actionLinks.run with a hardcoded method_id.

Common situations: An Apps Engine app publishes a new message version removing/renaming action links while the old message is still on screen; a jump-to-message renders an old cached copy; a custom integration emits method_ids the client message payload no longer contains.

Related errors


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

Appendix: source

Thrown at apps/meteor/client/lib/actionLinks.ts:27

	register(name: string, fn: (message: IMessage, params: string) => void): void {
		actionLinks.actions.set(name, fn);
	},
	run(actionMethodId: string, message: IMessage): void {
		const embedded = isLayoutEmbedded();

		if (embedded) {
			fireGlobalEvent('click-action-link', {
				actionlink: actionMethodId,
				value: message._id,
				message,
			});
			return;
		}

		const actionLink = message.actionLinks?.find((action) => action.method_id === actionMethodId);

		if (!actionLink) {
			throw new Error('error-invalid-actionlink');
		}

		if (!actionLinks.actions.has(actionLink.method_id)) {
			throw new Error('error-invalid-actionlink');
		}

		const fn = actionLinks.actions.get(actionLink.method_id);
		fn?.(message, actionLink.params);
	},
};

View on GitHub (pinned to b2c16d5842)