RocketChat/Rocket.Chat · error · Error

Message not found

Error message

Message not found

What it means

Thrown by useGetMessageByID's callback when the getMessage API call (REST endpoint for fetching a single message) returns an error object that has a 'success' property (the Rocket.Chat REST API error shape: { success: false, error: ..., ... }). The function catches the API error and re-throws it as a generic 'Message not found' Error, masking the original error details.

Source

Thrown at apps/meteor/client/views/room/contextualBar/Threads/hooks/useGetMessageByID.ts:25

import { Messages } from '../../../../../stores';

export const useGetMessageByID = (shouldStoreMessage: boolean = true) => {
	const getMessage = useEndpoint('GET', '/v1/chat.getMessage');
	const storeMessage = Messages.use((state) => state.store);

	return useCallback(
		async (mid: IMessage['_id']) => {
			try {
				const { message: rawMessage } = await getMessage({ msgId: mid });
				const mappedMessage = mapMessageFromApi(rawMessage);
				const message = (await onClientMessageReceived(mappedMessage)) || mappedMessage;
				if (shouldStoreMessage) {
					storeMessage(message);
				}
				return message;
			} catch (error) {
				if (typeof error === 'object' && error !== null && 'success' in error) {
					throw new Error('Message not found');
				}

				throw error;
			}
		},
		[getMessage, shouldStoreMessage, storeMessage],
	);
};

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Verify the message exists and the user has access before fetching by ID.
  2. Catch the 'Message not found' error in the consuming component and show appropriate UI.
  3. Note that this catch block loses the original API error details — for debugging, inspect the network response directly.
  4. For deleted messages, refresh the thread/room data to remove stale references.

Example fix

// before
const message = await getMessageByID(mid);
// after
try {
  const message = await getMessageByID(mid);
} catch (e) {
  if (e instanceof Error && e.message === 'Message not found') {
    // show 'message deleted or inaccessible' UI
    return;
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

const exists = Messages.state.get(mid);
if (!exists) {
  // optionally verify via API, or show 'not available'
  return;
}

Type guard

const isApiErrorResponse = (error: unknown): boolean =>
  typeof error === 'object' && error !== null && 'success' in error;

Try / catch

try {
  const message = await getMessageByID(mid);
} catch (e) {
  if (e instanceof Error && e.message === 'Message not found') {
    // message deleted, inaccessible, or API error
    showMessageDeletedState();
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: The message ID does not exist on the server. The message exists but the user lacks permission to read it. The message was deleted. The REST API returns success: false for any reason (rate limiting, server error) — the catch block treats all such errors as 'not found'.

Common situations: Loading a thread whose main message was deleted. User navigates to a message in a room they were removed from. Message ID from a stale link. Any API error with success: false is misreported as 'not found'.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/f8f739bb92d3c5ed. Report an issue: GitHub.