RocketChat/Rocket.Chat · error · Error
importer-message-unknown-user
Error message
importer-message-unknown-user
What it means
Thrown while an importer (Slack, HipChat, CSV, etc.) inserts messages: the message's creator (data.u._id) could not be resolved by ConverterCache.findImportedUser to a previously imported Rocket.Chat user. The error aborts that record; the import framework counts it as a failed message and continues with the rest.
Source
Thrown at apps/meteor/server/lib/import/classes/converters/MessageConverter.ts:59
protected async resetLastMessages(): Promise<void> {
for (const rid of this.rids) {
try {
await Rooms.resetLastMessageById(rid, null);
} catch (err) {
this._logger.error({ msg: 'Failed to update last message of room', roomId: rid, err });
}
}
}
protected async insertMessage(data: IImportMessage): Promise<void> {
if (!data.ts || isNaN(data.ts as unknown as number)) {
throw new Error('importer-message-invalid-timestamp');
}
const creator = await this._cache.findImportedUser(data.u._id);
if (!creator) {
this._logger.warn({ msg: 'Imported user not found', userId: data.u._id });
throw new Error('importer-message-unknown-user');
}
const rid = await this._cache.findImportedRoomId(data.rid);
if (!rid) {
throw new Error('importer-message-unknown-room');
}
if (!this.rids.includes(rid)) {
this.rids.push(rid);
}
const msgObj = await this.buildMessageObject(data, rid, creator);
try {
await insertMessage(creator, msgObj as unknown as IDBMessage, rid, true);
} catch (err) {
this._logger.error({ msg: 'Failed to import message', timestamp: msgObj.ts, roomId: rid, err });
}
}
View on GitHub (pinned to b2c16d5842)
Solutions
- Check the import log's earlier user-stage errors - missing users almost always originate there
- Re-export from the source including all users, so every message author is covered
- Pre-scan the export: collect message author ids and diff them against the user ids; add missing users or remap them to a placeholder account
- For custom importers, fully convert users before the message pass so ConverterCache can resolve ids
Example fix
// pre-flight check before running the import
const importedUsers = new Set(users.map((u) => u._id));
const missingAuthors = [...new Set(messages.map((m) => m.u?._id).filter(Boolean))].filter((id) => !importedUsers.has(id));
if (missingAuthors.length) {
console.warn('Messages reference unknown users:', missingAuthors);
// add them to the import data or remap to a placeholder user before importing
} Defensive patterns
Strategy: validation
Validate before calling
const importedUserIds = new Set(users.map((u) => u._id));
const missingAuthors = [...new Set(messages.map((m) => m.u?._id).filter(Boolean))].filter((id) => !importedUserIds.has(id));
if (missingAuthors.length) {
// add the missing users or remap them to a placeholder before importing messages
} Try / catch
try {
await converter.addMessage(message, useUpsert);
} catch (error) {
if ((error as Error).message === 'importer-message-unknown-user') {
logger.warn({ msg: 'skip message with unknown author', messageId: message._id });
return; // keep importing the remaining messages
}
throw error;
} Prevention
- Always import/convert users before messages so ConverterCache can resolve ids
- Pre-validate referential integrity of exports (authors, rooms) before starting
- Keep a placeholder user for deleted accounts from the source platform
When it happens
Trigger: A source export whose messages reference users absent from the users data (deleted/left accounts not in users.json); a partial import where the users stage failed earlier; custom importers that add messages before users are converted so the cache is cold.
Common situations: Slack workspaces with deleted accounts; export files trimmed by hand; import runs where user-stage errors were ignored until messages started referencing the missing users.
Related errors
- importer-channel-missing-users
- error-invalid-message
- Mentioned room not found
- Mentioned user not found
- Message converter not found
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/28541c73a24ab190.
Report an issue: GitHub.