RocketChat/Rocket.Chat · error

error-invalid-contact

error-invalid-contact

Error message

error-invalid-contact

What it means

While creating an omnichannel room for a visitor, Helper.ts runs migrateVisitorIfMissingContact and then loads the visitor's LivechatContact by ID with an enabled-only lookup; if no usable contact comes back it throws error-invalid-contact. It means the visitor-to-contact linkage is broken: migration produced no contact id, or the contact exists but is disabled.

Source

Thrown at apps/meteor/server/lib/omnichannel/Helper.ts:106

	);

	const extraRoomInfo = await beforeNewRoom(roomInfo, extraData);
	const { _id, username, token, department: departmentId, status = 'online' } = guest;
	const newRoomAt = new Date();
	const source = extraRoomInfo.source || roomInfo.source;

	if (settings.get<string>('Livechat_Require_Contact_Verification') === 'always') {
		await LivechatContacts.setChannelVerifiedStatus({ visitorId: _id, source }, false);
	}

	const contactId = await migrateVisitorIfMissingContact(_id, source);
	const contact =
		contactId &&
		(await LivechatContacts.findOneEnabledById<Pick<ILivechatContact, '_id' | 'name' | 'channels' | 'activity'>>(contactId, {
			projection: { name: 1, channels: 1, activity: 1 },
		}));
	if (!contact) {
		throw new Error('error-invalid-contact');
	}
	const verified = Boolean(contact.channels.some((channel) => isVerifiedChannelInSource(channel, _id, source)));

	const activity = guest.activity || contact.activity;
	logger.debug({
		msg: 'Creating livechat room for visitor',
		visitor: { _id, username, departmentId, status, activity },
	});

	// TODO: Solve `u` missing issue
	return {
		_id: rid,
		msgs: 0,
		usersCount: 1,
		lm: newRoomAt,
		fname: contact.name,
		t: 'l' as const,
		ts: newRoomAt,

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Inspect the livechat contacts collection for the visitor's contact _id and its disabled flag; re-enable or recreate it
  2. Edit the visitor's contact info in the Omnichannel Contacts panel to re-run contact migration
  3. Check server logs around migrateVisitorIfMissingContact for the underlying failure
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const room = await createRoom(...);
} catch (err) {
  if (err instanceof Error && err.message === 'error-invalid-contact') {
    // re-save the visitor's contact info (re-runs migration) then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: The omnichannel contact record was disabled or deleted in the contact management UI while its visitor still starts chats; migrateVisitorIfMissingContact failed during a contact merge; a new channel (WhatsApp/SMS) where contact creation raced with room creation.

Common situations: Contacts merged or disabled by supervisors during active conversations; contact collections left inconsistent after a restore or import; multi-channel contact management operations.

Related errors


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