RocketChat/Rocket.Chat · error · Error

User not provided

Error message

User not provided

What it means

Thrown by the users bridge update method when the user argument is falsy. The bridge dereferences user.id immediately after the guard, so a null/undefined user is rejected up front rather than producing a NullPointerException deeper in the call stack.

Source

Thrown at apps/meteor/app/apps/server/bridges/users.ts:134

		// It's actually not a problem if there is no App user to delete - just means we don't need to do anything more.
		if (!user) {
			return true;
		}

		try {
			await deleteUser(user.id);
		} catch (err) {
			throw new Error(`Errors occurred while deleting an app user: ${err}`);
		}

		return true;
	}

	protected async update(user: IUser & { id: string }, fields: Partial<IUser>, appId: string): Promise<boolean> {
		this.orch.debugLog(`The App ${appId} is updating a user`);

		if (!user) {
			throw new Error('User not provided');
		}

		const { status, statusText, ...updateFields } = fields;

		if (status) {
			await Presence.setStatus(user.id, status as UserStatus, statusText);
		} else if (typeof statusText === 'string') {
			await setStatusText(
				{
					_id: user.id,
					username: user.username,
					name: user.name,
					status: user.status as UserStatus,
					roles: user.roles,
					statusText: user.statusText,
				},
				statusText,
			);

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Check that the user object is defined and has an id before calling update.
  2. Resolve the user via convertById/getUserById and early-return on miss.
  3. Add a runtime guard at the boundary of your handler.

Example fix

// before
await users.update(found, fields);

// after
if (!found) {
  return;
}
await users.update(found, fields);
Defensive patterns

Strategy: validation

Validate before calling

if (!user || !user.id) {
  throw new Error('Cannot update: no user provided');
}

Type guard

function isDefinedUser(u: unknown): u is IUser & { id: string } {
  return !!u && typeof (u as any).id === 'string';
}

Prevention

When it happens

Trigger: App calls update with a null/undefined user object, typically because a preceding lookup returned nothing and was passed through unchecked.

Common situations: User lookup by id returned undefined (user deleted/not found) and the app forwarded the result to update; refactoring left a placeholder variable; event handler received an empty payload.

Related errors


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