nat
(Natalie T)
June 14, 2023, 11:16am
10
This one’s a fun bug.
Due to poll votes not merging properly, when we merge Lancelot (id 383) → Galahad (id 120), Lancelot actually would still exist, but not have a primary email - /admin/users/383/lancelot
would error with http 500 due to an anonymization check.
Anyway we’ve got a fix on the way. We’re favouring keeping Galahad’s (the target user) vote in this case of duplicates.
discourse:main
← discourse:user-merger-email-empty
opened 10:09AM - 14 Jun 23 UTC
This is somewhat of an uncommon case where if a plugin fails to merge a user, th… e merge would fail but the `user_email` of the `source_user` would have been transferred to the `target_user`. This leaves the `source_user` without an email, and this bug would occur when admins try to access `/admin/users/<id>/<username>`.
This allows the admin to continue dealing with the user.
https://meta.discourse.org/t/error-merging-users-with-duplicate-poll-votes/154711
A consideration here would be to use a transaction (probably very costly), or reorder the order of events in `UserMerger.merge!`
discourse:main
← discourse:de-duplicate-poll-vote-user-merge
opened 11:14AM - 14 Jun 23 UTC
Currently when merging users, polls may error out if the source and target users… have both voted on the same poll before. 😢
There is currently no constraint on the `poll_votes` table either to support this. Ideally a composite primary key can be used `(poll_id, user_id)`, but alas there is no support yet, which is probably why it wasn't created in the first place.
This fix ensures that merging is successful by only keeping the target poll votes if duplicates exist.
This fix also runs a migration on older poll votes where failed merges would have caused a single user to have voted twice on a single poll. e.g. this weird edge case
<img width="450" alt="Screenshot 2023-06-14 at 7 12 06 PM" src="https://github.com/discourse/discourse/assets/1555215/19d9ed06-2206-45f5-826f-e1c565f01bab">
Related: https://github.com/discourse/discourse/pull/22105
4 Likes