RocketChat/Rocket.Chat · error

User not provided

Error message

User not provided

What it means

The users bridge update refuses to proceed when the user argument is falsy. The call requires the existing user object (at minimum its id); passing undefined/null — often from an optional lookup that returned nothing — trips this guard before any field is written.

Solutions

  1. Fetch the user first (by id via the user reader) and abort when not found.
  2. Guard at the call site: if (!user) return; before updating.
  3. Ensure the user exists (bot/app creation) before attempting updates.

Example fix

// before
await updateUser(maybeUser, fields, appId); // maybeUser may be undefined

// after
if (!user) {
  throw new Error('Cannot update a user that does not exist');
}
await updateUser(user, fields, appId);
Defensive patterns

Strategy: validation

Validate before calling

if (!user || !user.id) {
  // nothing to update
  return;
}

Type guard

const isExistingUser = (u: IUser | null | undefined): u is IUser & { id: string } =>
  Boolean(u && u.id);

Prevention

When it happens

Trigger: App calls user update with a variable produced by a lookup that returned undefined (user gone, wrong id); destructuring a missing parameter; updating a user before it was created.

Common situations: Optional-chained lookups not guarded; app updating its bot user before the framework created it; races with uninstall removing the user mid-flow.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: 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 b2c16d5842)