{"record":{"id":"ec0c5160305d9763","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-actionlink","errorCode":null,"errorMessage":"error-invalid-actionlink","messagePattern":"error-invalid-actionlink","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/client/lib/actionLinks.ts#L9-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log message.actionLinks for the clicked message and confirm the method_id you pass actually exists in the array.","Re-fetch or refresh the message (e.g. via /v1/chat.getMessage) before running the link so the payload is current.","If you develop an app, keep method_id values stable across message updates to avoid stale-button clicks."],"exampleFix":"// before\nactionLinks.run(message, methodId);\n\n// after\nif (message.actionLinks?.some((a) => a.method_id === methodId)) {\n  actionLinks.run(message, methodId);\n}","handlingStrategy":"validation","validationCode":"const link = message.actionLinks?.find((a) => a.method_id === methodId);\nif (!link) return; // nothing to run\nactionLinks.run(message, methodId);","typeGuard":"const hasActionLink = (message: IMessage, methodId: string): boolean =>\n  Boolean(message.actionLinks?.some((a) => a.method_id === methodId));","tryCatchPattern":"try {\n  actionLinks.run(message, methodId);\n} catch (e) {\n  if (e instanceof Error && e.message === 'error-invalid-actionlink') {\n    // stale message: refresh it before retrying\n    await refreshMessage(message._id);\n    return;\n  }\n  throw e;\n}","preventionTips":["Re-fetch the message when its actionLinks-bearing UI is older than the latest server version.","Keep method_id values stable across app releases.","Only render action-link buttons for entries actually present in message.actionLinks."],"tags":["action-links","apps-engine","messages"],"backgroundTag":"invalid-action-link","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}