RocketChat/Rocket.Chat · error · Meteor.Error
invalid-user
invalid-user
Error message
invalid-user
What it means
Meteor.Error('invalid-user') thrown by sendResetNotification (the notification helper of resetUserE2EEncriptionKey) when Users.findOneById(uid) returns nothing. The E2E key reset notification cannot proceed for a user that does not exist.
Source
Thrown at apps/meteor/server/lib/resetUserE2EKey.ts:14
import { api } from '@rocket.chat/core-services';
import { Subscriptions, Users, Rooms } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
import { i18n } from './i18n';
import { isUserIdFederated } from './isUserIdFederated';
import * as Mailer from './notifications/email/api';
import { notifyOnUserChange, notifyOnSubscriptionChangedByUserId } from './notifyListener';
import { settings } from '../settings';
const sendResetNotification = async function (uid: string): Promise<void> {
const user = await Users.findOneById(uid, {});
if (!user) {
throw new Meteor.Error('invalid-user');
}
const language = user.language || settings.get('Language') || 'en';
const addresses = user.emails?.filter(({ verified }) => verified).map((e) => e.address);
if (!addresses?.length) {
return;
}
const t = i18n.getFixedT(language);
const text = `
${t('Your_e2e_key_has_been_reset')}
${t('E2E_Reset_Email_Content')}
`;
const html = `
<p>${t('Your_e2e_key_has_been_reset')}</p>
<p>${t('E2E_Reset_Email_Content')}</p>
`;View on GitHub (pinned to b2c16d5842)
Solutions
- Verify the user exists with a fresh lookup immediately before triggering the reset.
- Pass notifyUser=false when resetting keys for users that may have been deleted.
- In queued jobs, drop work items whose user no longer exists instead of failing.
Example fix
// before
await resetUserE2EEncriptionKey(uid, true); // throws invalid-user for deleted users
// after
const user = await Users.findOneById(uid, { projection: { _id: 1 } });
if (user) {
await resetUserE2EEncriptionKey(uid, true);
} Defensive patterns
Strategy: validation
Validate before calling
const user = await Users.findOneById(uid, { projection: { _id: 1 } });
if (!user) {
// skip the E2E key reset / notification: user is gone
} Try / catch
try {
await resetUserE2EEncriptionKey(uid, true);
} catch (error: any) {
if (error?.error === 'invalid-user') {
// drop the work item; nothing to reset
}
} Prevention
- Re-check user existence immediately before triggering key resets.
- Pass notifyUser=false when resetting keys for users that may have been deleted.
- In background jobs, drop work items whose user no longer exists.
When it happens
Trigger: Calling resetUserE2EEncriptionKey(uid, true) with a deleted or never-existing user id, or a user deleted between the admin action and processing.
Common situations: Admin resets an E2E key from a stale user list; background jobs referencing deleted users; user deleted while the reset flow is in flight.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/082b550350c05d68.
Report an issue: GitHub.