RocketChat/Rocket.Chat · error · MeteorError
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
LivechatEnterprise.addMonitor looks up the given username in the Users collection to promote that user to livechat-monitor. If no user matches, it throws Meteor error error-invalid-user with method livechat:addMonitor.
Solutions
- Verify the exact username first: GET /api/v1/users.info?username=<name>
- Copy the username from the user's profile to avoid casing/whitespace mistakes
- Create the user account before trying to make it a monitor
Defensive patterns
Strategy: validation
Validate before calling
const user = await Users.findOneByUsername(username, { projection: { _id: 1, roles: 1 } });
if (!user) {
// reject early with a clear 'username not found' message
}
await LivechatEnterprise.addMonitor(username); Try / catch
try {
await LivechatEnterprise.addMonitor(username);
} catch (err) {
if ((err as Meteor.Error)?.error === 'error-invalid-user') {
// show 'user not found' for the supplied username
} else {
throw err;
}
} Prevention
- Use autocomplete on existing usernames instead of free-text entry
- Trim whitespace and match exact casing when passing usernames
- Re-validate usernames when renaming users anywhere in the workspace
When it happens
Trigger: Calling livechat:addMonitor (Meteor method or REST /api/v1/livechat/monitors.add) with a username that does not exist, is misspelled, or differs in casing/whitespace.
Common situations: Frontend sending a stale username after the user was renamed or deleted; scripts referencing removed accounts; copy-paste with trailing spaces.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
- error-adding-monitor-role
- error-contact-manager-not-found
- error-contact-manager-not-found
- error-invalid-user
- invalid-user
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/1f2cd73f6272996a.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts:21
import { Users, OmnichannelServiceLevelAgreements, LivechatTag, LivechatUnitMonitors, LivechatUnit } from '@rocket.chat/models';
import { getUnitsFromUser } from '@rocket.chat/omni-core-ee';
import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { updateSLAInquiries } from './Helper';
import { removeSLAFromRooms } from './SlaHelper';
import { callbacks } from '../../../../server/lib/callbacks';
import { addUserRolesAsync } from '../../../../server/lib/roles/addUserRoles';
import { removeUserFromRolesAsync } from '../../../../server/lib/roles/removeUserFromRoles';
export const LivechatEnterprise = {
async addMonitor(username: string) {
const user = await Users.findOneByUsername<Pick<IUser, '_id' | 'username' | 'roles'>>(username, {
projection: { _id: 1, username: 1, roles: 1 },
});
if (!user) {
throw new MeteorError('error-invalid-user', 'Invalid user', {
method: 'livechat:addMonitor',
});
}
if (!(await addUserRolesAsync(user._id, ['livechat-monitor']))) {
throw new MeteorError('error-adding-monitor-role', 'Error adding monitor role', {
method: 'livechat:addMonitor',
});
}
return user;
},
async removeMonitor(username: string) {
const user = await Users.findOneByUsername<Pick<IUser, '_id'>>(username, {
projection: { _id: 1 },
});
View on GitHub (pinned to b2c16d5842)