RocketChat/Rocket.Chat · critical · Error

error-invalid-user

error-invalid-user

Error message

error-invalid-user

What it means

saveNavigationHistory (livechat visitor page tracking) authors its system messages as rocket.cat; it loads Users.findOneById('rocket.cat') and throws Error('error-invalid-user') when the document is missing. Like the transcript fallback, rocket.cat is a guaranteed system account, so its absence means the users collection was damaged (bad restore, migration, or a cleanup script that deleted system users).

Source

Thrown at apps/meteor/server/lib/omnichannel/tracking.ts:22

import { livechatLogger } from './logger';
import { settings } from '../../settings';

type PageInfo = { title: string; location: { href: string }; change: string };

export async function savePageHistory(token: string, roomId: string | undefined, pageInfo: PageInfo) {
	livechatLogger.debug({
		msg: `Saving page movement history for visitor with token ${token}`,
		pageInfo,
		roomId,
	});

	if (pageInfo.change !== settings.get<string>('Livechat_history_monitor_type')) {
		return;
	}
	const user = await Users.findOneById('rocket.cat');

	if (!user) {
		throw new Error('error-invalid-user');
	}

	const pageTitle = pageInfo.title;
	const pageUrl = pageInfo.location.href;
	const extraData: {
		navigation: {
			page: PageInfo;
			token: string;
		};
		expireAt?: number;
		_hidden?: boolean;
	} = {
		navigation: {
			page: pageInfo,
			token,
		},
	};

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Verify db.users.findOne({_id: 'rocket.cat'}) and recreate the system user if absent (copy document shape from a clean install of the same version)
  2. Find and fix whatever removes system users (cleanup jobs, LDAP/SCIM filters, import tooling)
  3. Re-test by visiting a livechat widget page with history monitoring enabled and confirming livechat_navigation_history messages are written
  4. Monitor logs for 'error-invalid-user' after the fix to confirm tracking recovered
Defensive patterns

Strategy: validation

Validate before calling

import { Users } from '@rocket.chat/models';

const cat = await Users.findOneById('rocket.cat');
if (!cat) {
  // refuse to process tracking events; alert ops that the system user is missing
  throw new Error('rocket.cat system user missing — navigation history cannot be recorded');
}

Prevention

When it happens

Trigger: A livechat visitor navigates pages with the history monitor active (pageInfo.change equals Livechat_history_monitor_type) on a deployment where the rocket.cat user was deleted — every page-tracking event then fails with this error.

Common situations: Same family as other rocket.cat-missing failures: scripts purging users, imports that skipped system accounts, broken migrations between major versions, or manual DB surgery.

Understand the failure class

Background: error-invalid-user: "Invalid user" errors in Rocket.Chat — what they mean and how to fix them — this error's family across 2 libraries.

Related errors


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