Budibase/budibase · error
Unable to delete self.
Error message
Unable to delete self.
What it means
bulkDelete iterates the requested user identifiers and rejects the whole operation if any target userId equals the currently authenticated user's id. This prevents a user from deleting their own account (which would break their session and tenant state). Called both directly by bulkDelete and via bulkUpdate flows that can delete.
Source
Thrown at packages/worker/src/api/controllers/global/users.ts:184
// Need to get the _rev of the user doc to update
const userById = await platform.users.getUserDoc(userByEmail.userId)
await platform.users.updateUserDoc({
...userById,
email,
ssoId,
})
ctx.body = { message: "SSO support added." }
} catch (err: any) {
ctx.throw(err.status || 400, err?.message || err)
}
}
const bulkDelete = async (
users: Array<UserIdentifier>,
currentUserId: string
) => {
if (users.find(u => u.userId === currentUserId)) {
throw new Error("Unable to delete self.")
}
return await userSdk.db.bulkDelete(users)
}
const bulkCreate = async (users: User[], groupIds: string[]) => {
if (!env.SELF_HOSTED && users.length > MAX_USERS_UPLOAD_LIMIT) {
throw new Error(
"Max limit for upload is 1000 users. Please reduce file size and try again."
)
}
return await userSdk.db.bulkCreate(users, groupIds)
}
export const bulkUpdate = async (
ctx: Ctx<BulkUserRequest, BulkUserResponse>
) => {
const currentUserId = ctx.user._id
const input = ctx.request.bodyView on GitHub (pinned to a81a902e9a)
Solutions
- Remove the current user's id from the delete list before calling the API
- In the UI, disable/deselect the row representing the logged-in admin
- Delete other users first and have another admin remove the last one if needed
- Handle the error response and inform the user they cannot delete their own account
Example fix
// before
await api.bulkDelete(allUsers.map(u => ({ userId: u._id })))
// after
const deletable = allUsers.filter(u => u._id !== currentUser._id)
await api.bulkDelete(deletable.map(u => ({ userId: u._id }))) Defensive patterns
Strategy: validation
Validate before calling
if (users.some(u => u.userId === currentUserId)) {
throw new Error("Cannot include the current user in a bulk delete")
} Type guard
null
Try / catch
try {
await api.bulkDelete(userIds)
} catch (e) {
if (e.message.includes("Unable to delete self")) {
notify("You cannot delete your own account")
}
} Prevention
- Filter out the logged-in user's id before submitting bulk deletes
- In admin UIs, prevent selecting your own account row
- Review bulk payloads in scripts for inclusion of the caller's id
When it happens
Trigger: Calling the bulk user delete endpoint (or a bulk update that routes into bulkDelete) with a payload that includes the current user's own userId among the users to delete.
Common situations: An admin selects 'all users' in a UI checkbox list including themselves; scripted cleanup that deletes every user in a tenant; stale client-side state where the admin's own row wasn't filtered out.
Related errors
- No user ID provided for getting
- Email is required
- Replacing members is not allowed
- Max limit for upload is 1000 users. Please reduce file size
- User must be provided for password recovery.
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/834a6f4f37926696.
Report an issue: GitHub.