RocketChat/Rocket.Chat · error · Error

Mention bot - Failed to retrieve path to room

Error message

Mention bot - Failed to retrieve path to room

What it means

Second guard in the mention bot's 'share-message' action: after finding the user's subscription, roomCoordinator.getRouteLink(sub.t, { rid: sub.rid, name: sub.name }) must resolve a web route for the subscription's room type. If no route is registered for that type on the server, no deep link can be built and the action aborts with this error.

Source

Thrown at apps/meteor/server/modules/core-apps/mention.module.ts:84

					lng: user.language,
				}),
				tmid: message.tmid,
				_id: payload.message,
				mentions,
			});
			return undefined;
		}

		if (actionId === 'share-message') {
			const sub = await Subscriptions.findOneByRoomIdAndUserId(room, user._id, { projection: { t: 1, rid: 1, name: 1 } });
			// this should exist since the event is fired from withing the room (e.g the user sent a message)
			if (!sub) {
				throw new Error('Mention bot - Failed to retrieve room information');
			}

			const roomPath = roomCoordinator.getRouteLink(sub.t, { rid: sub.rid, name: sub.name });
			if (!roomPath) {
				throw new Error('Mention bot - Failed to retrieve path to room');
			}

			const messageText = i18n.t('Youre_not_a_part_of__channel__and_I_mentioned_you_there', {
				channel: `#${sub.name}`,
				lng: user.language,
			});

			const link = new URL(Meteor.absoluteUrl(roomPath));
			link.searchParams.set('msg', message._id);
			const text = `[ ](${link.toString()})\n${messageText}`;

			// forwards message to all DMs
			await processWebhookMessage(
				{
					roomId: mentions.map(({ _id }) => _id),
					text,
					separateResponse: true, // so that messages are sent to other DMs even if one or more fails
				},

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Check the subscription's t field in the database and confirm that room type has a route registered server-side
  2. Register the missing route for the custom room type in its server-side room provider (roomCoordinator/roomProvider registration)
  3. Migrate or clean stale subscriptions that point at room types your build no longer supports
  4. Catch the error and fall back to a plain deep link (Meteor.absoluteUrl) so the share still works

Example fix

// before
const roomPath = roomCoordinator.getRouteLink(sub.t, { rid: sub.rid, name: sub.name }); // may be undefined -> throw

// after
const roomPath = roomCoordinator.getRouteLink(sub.t, { rid: sub.rid, name: sub.name }) ?? `channel/${sub.name ?? sub.rid}`;
Defensive patterns

Strategy: try-catch

Validate before calling

const roomTypeHasRoute = (t: string): boolean =>
  Boolean(roomCoordinator.getRouteLink(t, { rid: 'probe', name: 'probe' }));

Try / catch

try {
  await mentionModule.blockAction(payload);
} catch (error) {
  if (error instanceof Error && error.message === 'Mention bot - Failed to retrieve path to room') {
    // no route for this room type; fall back to a bare absolute URL
    return shareWithFallbackUrl(payload);
  }
  throw error;
}

Prevention

When it happens

Trigger: A subscription whose room type (sub.t) has no route registered in the server's roomCoordinator at runtime — a custom or fork-specific room type added without a server-side route registration, or a partial deploy where the room-type route provider did not load.

Common situations: Custom room types registered only on the client; enterprise/fork room types missing in a community build; stale subscription documents referencing a room type the deployment no longer supports.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/4345b9cc0d6b00f9. Report an issue: GitHub.