{"record":{"id":"b474eefa78c468b0","repo":"RocketChat/Rocket.Chat","slug":"errors-occurred-while-deleting-an-app-user-err","errorCode":null,"errorMessage":"Errors occurred while deleting an app user: ${err}","messagePattern":"Errors occurred while deleting an app user: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/users.ts","lineNumber":124,"sourceCode":"\t\t}\n\n\t\tvoid notifyOnUserChangeById({ clientAction: 'inserted', id: user._id });\n\n\t\treturn user._id;\n\t}\n\n\tprotected async remove(user: IUser & { id: string }, appId: string): Promise<boolean> {\n\t\tthis.orch.debugLog(`The App's user is being removed: ${appId}`);\n\n\t\t// It's actually not a problem if there is no App user to delete - just means we don't need to do anything more.\n\t\tif (!user) {\n\t\t\treturn true;\n\t\t}\n\n\t\ttry {\n\t\t\tawait deleteUser(user.id);\n\t\t} catch (err) {\n\t\t\tthrow new Error(`Errors occurred while deleting an app user: ${err}`);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprotected async update(user: IUser & { id: string }, fields: Partial<IUser>, appId: string): Promise<boolean> {\n\t\tthis.orch.debugLog(`The App ${appId} is updating a user`);\n\n\t\tif (!user) {\n\t\t\tthrow new Error('User not provided');\n\t\t}\n\n\t\tconst { status, statusText, ...updateFields } = fields;\n\n\t\tif (status) {\n\t\t\tawait Presence.setStatus(user.id, status as UserStatus, statusText);\n\t\t} else if (typeof statusText === 'string') {\n\t\t\tawait setStatusText(","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/users.ts#L106-L142","documentation":"The users bridge wraps deleteUser for the app user; any failure of the deletion routine is rethrown as 'Errors occurred while deleting an app user: <inner error>'. The text after the colon carries the actual cause — commonly the server refusing to delete a user that still owns channels or has other active responsibilities.","triggerScenarios":"Uninstalling an app whose bot user is owner/creator of channels or has open livechat rooms; the underlying deleteUser routine throwing (rooms to transfer, last owner, db unreachable) during uninstall.","commonSituations":"App created channels during its lifetime that were never transferred or deleted; partially failed uninstalls leaving inconsistent state; uninstall racing other operations.","solutions":["Read the inner error text after the colon — it names the exact server-side refusal (e.g. rooms that must be transferred).","Transfer ownership or delete the rooms the bot user owns, then retry the uninstall.","If state is inconsistent (app record gone but user remains), remove the leftover app user manually and clean up before reinstalling."],"exampleFix":"// before - uninstall fails opaquely\n// after - surface the wrapped cause and act on it\ntry {\n  await removeUser(user, appId);\n} catch (err) {\n  const reason = String(err).replace(/^Errors occurred while deleting an app user: /, '');\n  // e.g. 'User owns rooms...' -> transfer/delete those rooms, then retry once\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch, strip the wrapper prefix, and branch on the inner message: mentions rooms -> transfer/delete owned rooms then retry the uninstall once; anything else -> abort and surface to the admin.","preventionTips":["Transfer or delete rooms created by the app before uninstalling.","Include this error in uninstall runbooks with the rooms-transfer remedy.","Inspect the appended inner error, not just the wrapper text."],"tags":["apps-engine","app-uninstall","user-deletion","bot-user"],"backgroundTag":"user-deletion-failed","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"}