{"record":{"id":"fbadff9cb6ba64f0","repo":"RocketChat/Rocket.Chat","slug":"the-user-for-app-appid-is-not-registered","errorCode":null,"errorMessage":"The user for app ${appId} is not registered.","messagePattern":"The user for app (.+?) is not registered\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/oauthApps.ts","lineNumber":21,"sourceCode":"import type { IAppServerOrchestrator } from '@rocket.chat/apps';\nimport { OAuthAppsBridge } from '@rocket.chat/apps/dist/server/bridges/OAuthAppsBridge';\nimport type { IOAuthApp, IOAuthAppParams } from '@rocket.chat/apps-engine/definition/accessors/IOAuthApp';\nimport type { IOAuthApps } from '@rocket.chat/core-typings';\nimport { OAuthApps, Users } from '@rocket.chat/models';\nimport { Random } from '@rocket.chat/random';\n\nexport class AppOAuthAppsBridge extends OAuthAppsBridge {\n\tconstructor(private readonly orch: IAppServerOrchestrator) {\n\t\tsuper();\n\t}\n\n\tprotected async create(oAuthApp: IOAuthAppParams, appId: string): Promise<string | null> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating a new OAuth app.`);\n\t\tconst { clientId, clientSecret } = oAuthApp;\n\t\tconst botUser = await Users.findOne({ appId });\n\n\t\tif (!botUser) {\n\t\t\tthrow new Error(`The user for app ${appId} is not registered.`);\n\t\t}\n\n\t\tconst { _id, username } = botUser;\n\n\t\treturn (\n\t\t\tawait OAuthApps.insertOne({\n\t\t\t\t...oAuthApp,\n\t\t\t\t_id: randomUUID(),\n\t\t\t\tappId,\n\t\t\t\tclientId: clientId ?? Random.id(),\n\t\t\t\tclientSecret: clientSecret ?? Random.secret(),\n\t\t\t\t_createdAt: new Date(),\n\t\t\t\t_createdBy: {\n\t\t\t\t\t_id,\n\t\t\t\t\tusername,\n\t\t\t\t},\n\t\t\t} as unknown as IOAuthApps)\n\t\t).insertedId;","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/oauthApps.ts#L3-L39","documentation":"AppOAuthAppsBridge.create resolves the calling app's bot user with Users.findOne({ appId }) to attach the OAuth client to a real user; if no user document carries that appId the OAuth app cannot be created and the bridge throws. The message interpolates the appId so you can tell which app failed.","triggerScenarios":"An app creates an OAuth client during install/activation before its bot user was provisioned; the bot user was deleted from Administration → Users; the database was restored/reset while the app remained installed; an appId mismatch between the app record and the user document.","commonSituations":"Apps that register OAuth clients in onInstall/onActivate; dev workspaces after mongo resets or migrations; operators cleaning up 'app bot' users manually; partial/failed app installations.","solutions":["Reinstall (or disable and re-enable) the app so Rocket.Chat re-provisions its bot user","Verify a user document with field appId equal to your appId exists (Administration → Users, or a direct mongo query on the users collection)","Never delete the bot user created for an installed app","If it persists on a stock install, report upstream with the appId from the error message"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const clientId = await app.getRocketChat().getOAuthApps().create(oauthAppParams);\n  app.getLogger().info('oauth app created', clientId);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('is not registered')) {\n    // bot user missing: surface instructions or retry after reinstall\n    app.getLogger().error('App bot user missing — reinstall the app to re-provision it');\n    return;\n  }\n  throw err;\n}","preventionTips":["Create OAuth clients lazily (on first use), not in onInstall, to avoid racing bot-user provisioning","Never delete the bot user belonging to an installed app","After workspace DB restores, re-enable/reinstall apps before they run","Include the appId from the error message when reporting issues"],"tags":["apps-engine","oauth","bot-user","install","user-not-found"],"backgroundTag":"app-bot-user-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}