{"record":{"id":"9b8219bd796c0d70","repo":"RocketChat/Rocket.Chat","slug":"invalid-message-id-9b8219","errorCode":null,"errorMessage":"Invalid message ID.","messagePattern":"Invalid message ID\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/messages/updateMessage.ts","lineNumber":25,"sourceCode":"import { afterSaveMessage } from '../../hooks/messages/afterSaveMessage';\nimport { settings } from '../../settings';\nimport { validateCustomMessageFields } from '../messaging/validateCustomMessageFields';\nimport { notifyOnRoomChangedById } from '../notifyListener';\n\nexport const updateMessage = async function (\n\t{\n\t\tparseUrls,\n\t\t...message\n\t}: (AtLeast<IMessage, '_id' | 'rid' | 'msg' | 'customFields'> | AtLeast<IMessage, '_id' | 'rid' | 'content'>) & {\n\t\tparseUrls?: boolean;\n\t},\n\tuser: IUser,\n\toriginalMsg?: IMessage,\n\tpreviewUrls?: string[],\n): Promise<void> {\n\tconst originalMessage = originalMsg || (await Messages.findOneById(message._id));\n\tif (!originalMessage) {\n\t\tthrow new Error('Invalid message ID.');\n\t}\n\n\tlet messageData: IMessage = Object.assign({}, originalMessage, message);\n\n\t// For the Rocket.Chat Apps :)\n\tif (message && Apps.self && Apps.isLoaded()) {\n\t\tconst prevent = await Apps.self?.triggerEvent(AppEvents.IPreMessageUpdatedPrevent, messageData);\n\t\tif (prevent) {\n\t\t\tthrow new Meteor.Error('error-app-prevented-updating', 'A Rocket.Chat App prevented the message updating.');\n\t\t}\n\n\t\tlet result = await Apps.self?.triggerEvent(AppEvents.IPreMessageUpdatedExtend, messageData);\n\t\tresult = await Apps.self?.triggerEvent(AppEvents.IPreMessageUpdatedModify, result);\n\n\t\tif (typeof result === 'object') {\n\t\t\tObject.assign(messageData, result);\n\t\t}\n\t}","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/messages/updateMessage.ts#L7-L43","documentation":"Error \"Invalid message ID.\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/lib/messages/updateMessage.ts:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the _id of an existing message to updateMessage; no message was found with the given id.","Verify the message has not been deleted before attempting to update it."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}