{"record":{"id":"6299fb443636e82a","repo":"RocketChat/Rocket.Chat","slug":"error-message-not-found-6299fb","errorCode":"error-message-not-found","errorMessage":"Message not found","messagePattern":"Message not found","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/translateMessage.ts","lineNumber":29,"sourceCode":"\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\t'autoTranslate.translateMessage'(message: IMessage | undefined, targetLanguage: string): Promise<IMessage | undefined>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync 'autoTranslate.translateMessage'(message, targetLanguage) {\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'autoTranslate.translateMessage',\n\t\t\t});\n\t\t}\n\t\tcheck(message?._id, String);\n\t\tcheck(targetLanguage, String);\n\t\tconst msg = await Messages.findOneById(message._id);\n\t\tif (!msg) {\n\t\t\tthrow new Meteor.Error('error-message-not-found', 'Message not found');\n\t\t}\n\t\tconst room = await Rooms.findOneById(msg.rid);\n\t\tif (!room || !(await canAccessRoomAsync(room, { _id: userId }))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed');\n\t\t}\n\t\treturn translateMessage(targetLanguage, msg);\n\t},\n});\n","sourceCodeStart":11,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/translateMessage.ts#L11-L38","documentation":"'autoTranslate.translateMessage' resolves the message via Messages.findOneById(message._id) and throws error-message-not-found when no document matches. It fires after auth and check() succeed, so it is purely a data-lookup failure: the _id the client sent does not exist (anymore) in the Messages collection. Most often the message was deleted or pruned after the client rendered it.","triggerScenarios":"Translating a message that was deleted, pruned, or removed by moderation after it was rendered; passing a fabricated or truncated _id; racing a message purge job.","commonSituations":"Stale message lists in long-open channels; messages deleted by moderators while a user hovered the translate action; imports/migrations where message _ids changed.","solutions":["Re-fetch the message by _id (or revalidate against the local message store) before offering/performing translation.","Catch the error and degrade gracefully - hide the translate action or show 'message no longer available'.","If it reproduces consistently, log the exact _id sent and compare it with the document in the Messages collection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// client-side: confirm the message is still in the local store before translating\nif (!message?._id || !RocketChat.models?.Messages?.findOne(message._id)) {\n\t// message no longer available - skip translation\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait Meteor.callAsync('autoTranslate.translateMessage', { _id }, lang);\n} catch (e: any) {\n\tif (e?.error === 'error-message-not-found') {\n\t\t// drop the message from local state; do not retry with the same id\n\t}\n}","preventionTips":["Remove deleted messages from local state when delete events arrive.","Revalidate the _id against the message cache right before calling.","Treat not-found as terminal - never auto-retry the same id."],"tags":["meteor-methods","auto-translate","not-found","messages"],"backgroundTag":"record-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}