RocketChat/Rocket.Chat · warning

Mentioned user not found

Error message

Mentioned user not found

What it means

During message import, an @mention could not be resolved to an imported user (findImportedUser returned nothing) and the mention is skipped: the user is omitted from the mentions array and the raw imported id remains in the text. Non-fatal. Distinct from importer-message-mentioned-username-not-found, which is thrown when the user DOES resolve but has no username.

Source

Thrown at apps/meteor/server/lib/import/classes/converters/MessageConverter.ts:165

			return undefined;
		}

		const result: MentionedUser[] = [];
		for (const importId of mentions) {
			if (importId === ('all' as 'string') || importId === 'here') {
				result.push({
					_id: importId,
					username: importId,
				});
				continue;
			}

			// Loading the name will also store the remaining data on the cache if it's missing, so this won't run two queries
			const name = await this._cache.findImportedUserDisplayName(importId);
			const data = await this._cache.findImportedUser(importId);

			if (!data) {
				this._logger.warn({ msg: 'Mentioned user not found', importId });
				continue;
			}

			if (!data.username) {
				this._logger.debug({ msg: 'Mentioned user has no username', importId });
				throw new Error('importer-message-mentioned-username-not-found');
			}

			message.msg = message.msg.replace(new RegExp(`\@${importId}`, 'gi'), `@${data.username}`);

			result.push({
				_id: data._id,
				username: data.username as 'string',
				name,
			});
		}
		return result;
	}

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Include the mentioned users in the import data (re-export with all users, including bots)
  2. Map missing mentionees to a placeholder user id before importing
  3. After import, sweep message texts for leftover raw mention ids and rewrite or strip them
Defensive patterns

Strategy: validation

Validate before calling

const importedUserIds = new Set(users.map((u) => u._id));
const sanitizeMentions = (msg: IImportMessage) => ({
  ...msg,
  mentions: (msg.mentions ?? []).filter((id) => id === 'all' || id === 'here' || importedUserIds.has(id)),
});

Prevention

When it happens

Trigger: Messages mentioning users excluded from the import: bots and deactivated accounts missing from the source export's user list, or users dropped by an earlier partial import.

Common situations: Same class as unknown message authors: partial exports, deleted source accounts, bot users omitted from users.json, hand-trimmed export files.

Related errors


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