Cannot delete user who is in a group

AI-generated summary

Users reported an issue where they couldn’t delete a user who was in a group, even when no posts existed — deletion only succeeded after removing the user from the group. pfaffman initially suspected it might be related to SSO, but omarfilip confirmed the same behavior with an SSO-created user manually added to a group. jomaxro asked for logs, which omarfilip provided via a linked topic. neil later confirmed the bug was fixed, explaining it occurred when a group granted a trust level — the issue stemmed from the order of dependent: destroy in the code. The fix is documented in this commit. pfaffman humorously attributed the issue to “gremlins” before the root cause was identified.

Hey., @jomaxro, working with a hosted customer today we tried to delete a user.

There was a message that the user had posts and couldn’t be deleted, but there were no posts, but the user was in a group. When we deleted the user from group it was possible to delete the user.

Any chance you grabbed the logs from the failed deletion? I can try again, but last I tried on try I was able to successfully delete a user who was in a group on try.discourse.org.

Then it must have been gremlins.

I had that same issue:

https://meta.discourse.org/t/cannot-delete-user-make-sure-all-posts-are-deleted/25233/62?u=omarfilip

Yeah, but that’s SSO, so only the SSO master can delete users.

Hmm - could be. The user was created via SSO, but added to the group manually in Discourse. I was able to delete him only after removing him from the group.

BTW, the log is posted in the topic I linked.

Pretty sure I fixed this today. It happens when one of the groups the user belongs to grants a trust level.

https://github.com/discourse/discourse/commit/5ce817766253e91b77273dd15d443d739387b5fa

The order of dependent: destroy matters. :bulb:

14 Likes