RocketChat/Rocket.Chat · error · Error

The user for app ${appId} is not registered.

Error message

The user for app ${appId} is not registered.

What it means

Thrown by AppOAuthAppsBridge.create when no user document exists in the Users collection with the given appId. Rocket.Chat stores an App's bot identity as a user record tagged with appId; the OAuth app is then attributed to that bot user via _createdBy. Without the bot user the bridge cannot populate the audit fields and refuses to insert a dangling OAuth app.

Source

Thrown at apps/meteor/app/apps/server/bridges/oauthApps.ts:21

import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import { OAuthAppsBridge } from '@rocket.chat/apps/dist/server/bridges/OAuthAppsBridge';
import type { IOAuthApp, IOAuthAppParams } from '@rocket.chat/apps-engine/definition/accessors/IOAuthApp';
import type { IOAuthApps } from '@rocket.chat/core-typings';
import { OAuthApps, Users } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';

export class AppOAuthAppsBridge extends OAuthAppsBridge {
	constructor(private readonly orch: IAppServerOrchestrator) {
		super();
	}

	protected async create(oAuthApp: IOAuthAppParams, appId: string): Promise<string | null> {
		this.orch.debugLog(`The App ${appId} is creating a new OAuth app.`);
		const { clientId, clientSecret } = oAuthApp;
		const botUser = await Users.findOne({ appId });

		if (!botUser) {
			throw new Error(`The user for app ${appId} is not registered.`);
		}

		const { _id, username } = botUser;

		return (
			await OAuthApps.insertOne({
				...oAuthApp,
				_id: randomUUID(),
				appId,
				clientId: clientId ?? Random.id(),
				clientSecret: clientSecret ?? Random.secret(),
				_createdAt: new Date(),
				_createdBy: {
					_id,
					username,
				},
			} as unknown as IOAuthApps)
		).insertedId;

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Ensure create is only called after the App's IPostAppInstall or later lifecycle hook where the bot user is guaranteed to exist.
  2. Verify the bot user with `Users.findOne({ appId })` (or the users accessor) before calling create, and surface a clear error.
  3. If the bot user was deleted, reinstall the App so the installation lifecycle recreates it.
  4. Confirm the appId you pass matches the id under which the App was installed.

Example fix

// before
// called inside onPreInstall
await oauthApps.create(params, appId);

// after
// called inside onPostInstall or later
const bot = await users.getAppUser(appId);
if (!bot) throw new Error('Bot user not provisioned yet');
await oauthApps.create(params, appId);
Defensive patterns

Strategy: validation

Validate before calling

const botUser = await users.getAppUser(appId); // or Users.findOne({ appId })
if (!botUser) {
  throw new Error(`Cannot create OAuth app: bot user for ${appId} is not provisioned. Reinstall the App or move the call to onPostInstall.`);
}
await oauthApps.create(params, appId);

Try / catch

try {
  return await oauthApps.create(params, appId);
} catch (e) {
  if (e instanceof Error && /not registered/.test(e.message)) {
    // bot user missing — defer or reinstall
    this.app.getLogger().error('OAuth app create failed: bot user missing. Reinstall the App.');
    throw e;
  }
  throw e;
}

Prevention

When it happens

Trigger: An App calls the OAuth apps accessor's create method before its own installation lifecycle has provisioned the bot user, or after the bot user was deleted (e.g. the App was uninstalled but a leftover code path still runs, or the App is running in a degraded state after a failed install). Also possible if appId was passed incorrectly and does not match the user record's appId field.

Common situations: Calling create during the App's constructor or onAppInitialize before the orchestrator has registered the bot user; reinstalling an App whose previous bot user was manually purged from the DB; multi-instance setups where the user write has not yet replicated; passing the wrong appId after an App was re-installed under a new id.

Related errors


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