{"record":{"id":"ec0c5160305d9763","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-actionlink","errorCode":"error-invalid-actionlink","errorMessage":"error-invalid-actionlink","messagePattern":"error-invalid-actionlink","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/meteor/client/lib/actionLinks.ts","lineNumber":27,"sourceCode":"\tregister(name: string, fn: (message: IMessage, params: string) => void): void {\n\t\tactionLinks.actions.set(name, fn);\n\t},\n\trun(actionMethodId: string, message: IMessage): void {\n\t\tconst embedded = isLayoutEmbedded();\n\n\t\tif (embedded) {\n\t\t\tfireGlobalEvent('click-action-link', {\n\t\t\t\tactionlink: actionMethodId,\n\t\t\t\tvalue: message._id,\n\t\t\t\tmessage,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst actionLink = message.actionLinks?.find((action) => action.method_id === actionMethodId);\n\n\t\tif (!actionLink) {\n\t\t\tthrow new Error('error-invalid-actionlink');\n\t\t}\n\n\t\tif (!actionLinks.actions.has(actionLink.method_id)) {\n\t\t\tthrow new Error('error-invalid-actionlink');\n\t\t}\n\n\t\tconst fn = actionLinks.actions.get(actionLink.method_id);\n\t\tfn?.(message, actionLink.params);\n\t},\n};\n","sourceCodeStart":9,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/lib/actionLinks.ts#L9-L38","documentation":"Thrown by actionLinks.run when no actionLink on the message matches the requested actionMethodId. The function searches message.actionLinks for an entry whose method_id equals actionMethodId; if none is found it throws 'error-invalid-actionlink'. This mirrors the server-side error code so the client and server share vocabulary.","triggerScenarios":"Calling actionLinks.run(actionMethodId, message) where the message has no actionLinks array, or none of its entries have method_id === actionMethodId. Common when a UI button references an action link that was never attached to the message (e.g. a stale message object, a button rendered for the wrong message type).","commonSituations":"The message is a plain text message with no action links but the UI still rendered an action button; the actionLink was removed by an edit; the method_id was renamed; a bot/integration attached an action link the client does not expect; clicking an action button after navigating away and the message ref is stale.","solutions":["Verify message.actionLinks exists and contains an entry with method_id === actionMethodId before calling run.","Ensure the UI only renders action buttons for messages that actually carry the relevant action link.","If the message was edited/updated, re-fetch it so actionLinks reflects the latest state.","Catch 'error-invalid-actionlink' and hide/disable the button gracefully."],"exampleFix":"// before\nactionLinks.run(actionMethodId, message);\n\n// after\nconst link = message.actionLinks?.find((a) => a.method_id === actionMethodId);\nif (link) {\n  actionLinks.run(actionMethodId, message);\n}","handlingStrategy":"validation","validationCode":"const link = message.actionLinks?.find((a) => a.method_id === actionMethodId);\nif (!link) { throw new Error('Action link not attached to message'); }","typeGuard":"function messageHasActionLink(message: IMessage, methodId: string): boolean {\n  return Array.isArray(message.actionLinks) &&\n    message.actionLinks.some((a) => a.method_id === methodId);\n}","tryCatchPattern":"try {\n  actionLinks.run(actionMethodId, message);\n} catch (e) {\n  if ((e as Error).message === 'error-invalid-actionlink') {\n    hideActionButton();\n  }\n}","preventionTips":["Only render action buttons for messages whose actionLinks contain the method_id.","Re-fetch edited messages so actionLinks reflect the latest state.","Catch 'error-invalid-actionlink' to disable stale buttons."],"tags":["action-links","message","validation","integration"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}