RocketChat/Rocket.Chat · error · Meteor.Error
error-message-not-found
error-message-not-found
Error message
The provided "messageId" does not match any existing message.
What it means
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.
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
Defensive patterns
Strategy: validation
Validate before calling
const msg = await GET('/api/v1/chat.syncMessages', { roomId, lastUpdate });
const exists = msg.messages.some((m) => m._id === messageId);
if (!exists) throw new Error('Message no longer exists; cannot pin'); Try / catch
try { await POST('/api/v1/chat.pinMessage', { messageId }); } catch (e) {
if (e.error === 'error-message-not-found') { /* refresh room; drop pin action */ }
} Prevention
- Pass only message IDs previously returned by the API
- Refresh message state on focus to catch deletions and retention purges
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error-message-not-found
- invalid-calendar-event
- Banner not found
- Cannot send system messages using 'chat.sendMessage'
- Emoji not found.
AI-assisted analysis of RocketChat/Rocket.Chat@e4b8178b20 (2026-08-18).
Data as JSON: /api/errors/faa372ac5d22831e.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/chat.ts:216
200: ajv.compile<{ message: IMessage }>({
type: 'object',
properties: {
message: { $ref: '#/components/schemas/IMessage' },
success: {
type: 'boolean',
enum: [true],
},
},
required: ['message', 'success'],
additionalProperties: false,
}),
},
},
async function action() {
const msg = await Messages.findOneById(this.bodyParams.messageId);
if (!msg) {
throw new Meteor.Error('error-message-not-found', 'The provided "messageId" does not match any existing message.');
}
const pinnedMessage = await pinMessage(msg, this.userId);
const [message] = await normalizeMessagesForUser([pinnedMessage], this.userId);
return API.v1.success({
message,
});
},
)
.post(
'chat.unPinMessage',
{
authRequired: true,
body: isChatUnpinMessageProps,
response: {
400: validateBadRequestErrorResponse,View on GitHub (pinned to e4b8178b20)