{"record":{"id":"faa372ac5d22831e","repo":"RocketChat/Rocket.Chat","slug":"error-message-not-found","errorCode":"error-message-not-found","errorMessage":"The provided \"messageId\" does not match any existing message.","messagePattern":"The provided \"messageId\" does not match any existing message\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/chat.ts","lineNumber":216,"sourceCode":"\t\t\t\t200: ajv.compile<{ message: IMessage }>({\n\t\t\t\t\ttype: 'object',\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tmessage: { $ref: '#/components/schemas/IMessage' },\n\t\t\t\t\t\tsuccess: {\n\t\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\t\tenum: [true],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\trequired: ['message', 'success'],\n\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t}),\n\t\t\t},\n\t\t},\n\t\tasync function action() {\n\t\t\tconst msg = await Messages.findOneById(this.bodyParams.messageId);\n\n\t\t\tif (!msg) {\n\t\t\t\tthrow new Meteor.Error('error-message-not-found', 'The provided \"messageId\" does not match any existing message.');\n\t\t\t}\n\n\t\t\tconst pinnedMessage = await pinMessage(msg, this.userId);\n\n\t\t\tconst [message] = await normalizeMessagesForUser([pinnedMessage], this.userId);\n\n\t\t\treturn API.v1.success({\n\t\t\t\tmessage,\n\t\t\t});\n\t\t},\n\t)\n\t.post(\n\t\t'chat.unPinMessage',\n\t\t{\n\t\t\tauthRequired: true,\n\t\t\tbody: isChatUnpinMessageProps,\n\t\t\tresponse: {\n\t\t\t\t400: validateBadRequestErrorResponse,","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/chat.ts#L198-L234","documentation":"Meteor error error-message-not-found thrown by POST chat.pinMessage when Messages.findOneById(messageId) returns null: no message with that _id exists (already deleted, never existed, or from another workspace). The pin attempt aborts before any permission checks on pinning run.","triggerScenarios":"POST /api/v1/chat.pinMessage with a messageId that was deleted, a malformed/truncated ID, or an ID fabricated by the client. Also when racing a message deletion: the message disappears between UI render and the pin call.","commonSituations":"User clicks pin on a message that was just deleted in another session; message purge/retention policies removed old messages; copy-paste ID typos; test scripts reusing fixtures against a reset database.","solutions":["Verify the message still exists (GET chat.syncMessages or the room history) before offering/retrying pin","Treat this error as terminal for that messageId: refresh the room and drop the pin action","Ensure you pass the message _id string exactly as returned by the API, not a client-generated identifier"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const msg = await GET('/api/v1/chat.syncMessages', { roomId, lastUpdate });\nconst exists = msg.messages.some((m) => m._id === messageId);\nif (!exists) throw new Error('Message no longer exists; cannot pin');","typeGuard":null,"tryCatchPattern":"try { await POST('/api/v1/chat.pinMessage', { messageId }); } catch (e) {\n  if (e.error === 'error-message-not-found') { /* refresh room; drop pin action */ }\n}","preventionTips":["Pass only message IDs previously returned by the API","Refresh message state on focus to catch deletions and retention purges"],"tags":["rest-api","chat","messages","pin","not-found","rocket-chat"],"backgroundTag":"message-not-found","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}