{"record":{"id":"08f419c4bf1726f1","repo":"RocketChat/Rocket.Chat","slug":"invalid-message","errorCode":null,"errorMessage":"invalid-message","messagePattern":"invalid-message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/message.ts","lineNumber":104,"sourceCode":"\t{ validateParams: { GET: isGETLivechatMessageIdParams, PUT: isPUTLivechatMessageIdParams, DELETE: isDELETELivechatMessageIdParams } },\n\t{\n\t\tasync get() {\n\t\t\tconst { token, rid } = this.queryParams;\n\t\t\tconst { _id } = this.urlParams;\n\n\t\t\tconst guest = await findGuest(token);\n\t\t\tif (!guest) {\n\t\t\t\tthrow new Error('invalid-token');\n\t\t\t}\n\n\t\t\tconst room = await findRoom(token, rid);\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('invalid-room');\n\t\t\t}\n\n\t\t\tlet message = await Messages.findOneByRoomIdAndMessageId(rid, _id);\n\t\t\tif (!message) {\n\t\t\t\tthrow new Error('invalid-message');\n\t\t\t}\n\n\t\t\tif (message.file) {\n\t\t\t\tmessage = { ...(await normalizeMessageFileUpload(message)), ...{ _updatedAt: message._updatedAt } };\n\t\t\t}\n\n\t\t\tif (!message) {\n\t\t\t\tthrow new Error('invalid-message');\n\t\t\t}\n\n\t\t\treturn API.v1.success({ message });\n\t\t},\n\n\t\tasync put() {\n\t\t\tconst { token, rid } = this.bodyParams;\n\t\t\tconst { _id } = this.urlParams;\n\n\t\t\tconst guest = await findGuest(token);","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/omnichannel/message.ts#L86-L122","documentation":"Thrown by GET /livechat/message/:_id (message.ts:102-105) when Messages.findOneByRoomIdAndMessageId(rid, _id) returns null — no message with that `_id` exists in room `rid`. The lookup is scoped by room, so a messageId that exists in another room still yields null. Returns HTTP 400 { success:false, error:'invalid-message' }.","triggerScenarios":"GET /livechat/message/:_id with a messageId that does not exist in the given room (wrong id, or message from a different room, or deleted).","commonSituations":"Wrong message id; message belongs to a different room; message was deleted/edited-away.","solutions":["Verify the message belongs to the room via Messages.findOneByRoomIdAndMessageId(rid, _id) before calling.","Use a messageId obtained from the room's own message history."],"exampleFix":"// before\nGET /livechat/message/:msgId?token&rid // invalid-message if not in rid\n\n// after\nconst msg = await Messages.findOneByRoomIdAndMessageId(rid, msgId);\nif (!msg) return notFound();\n// proceed to GET","handlingStrategy":"validation","validationCode":"const msg = await Messages.findOneByRoomIdAndMessageId(rid, _id);\nif (!msg) throw new Error('message not in this room');\n// safe to GET /livechat/message/:_id","typeGuard":"const messageInRoom = async (rid: string, msgId: string) =>\n  !!(await Messages.findOneByRoomIdAndMessageId(rid, msgId, { projection: { _id: 1 } }));","tryCatchPattern":"try { await getMessage({ _id, token, rid }); }\ncatch (e) { if (e instanceof Error && e.message === 'invalid-message') { /* 404: wrong/removed message */ } else throw e; }","preventionTips":["Fetch message ids only from the room's own history.","Don't reuse ids across rooms."],"tags":["livechat","omnichannel","message","room","rest-api"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}