{"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":"Error","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/users.ts#L106-L142","documentation":"Thrown by the users bridge remove method when the underlying deleteUser call rejects. The bridge wraps deleteUser in try/catch and re-throws a wrapped error that interpolates the original via `${err}`, losing the original error type but preserving its message.","triggerScenarios":"App uninstall/remove flow deletes its bot user and deleteUser fails — e.g. the user is the last owner of a room, has active livechat sessions, is referenced by other collections, or a database error occurs.","commonSituations":"Bot user is owner of channels that would be left ownerless; user has open livechat rooms; concurrent modification or DB connectivity issue; cascading delete blocked by a server-side guard.","solutions":["Inspect the interpolated inner error message to find the real cause (it is stringified after the colon).","Reassign ownership of rooms owned by the bot user before removal.","Retry after resolving the dependency; if persistent, remove the user manually via admin tooling."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await users.remove(user, appId);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Errors occurred while deleting an app user')) {\n    // inspect inner cause; resolve room ownership / dependencies, then retry\n  } else {\n    throw err;\n  }\n}","preventionTips":["Reassign ownership of rooms owned by the bot user before removal.","Inspect the interpolated inner error text for the real cause.","Clean up dependencies before uninstalling the app."],"tags":["apps-engine","users","deletion","dependency","wrapped-error"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}