GPT-6.1 Sol · Heavy
fix-proper-handling-of-group-memberships-discourse-cursor
Discourse · Ruby · L · 300–799 lines · 6 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.
- Gold bugs found
- 5 of 10
- Comments published
- 8
- Comments matching a bug
- 5
- Comments not matching
- 3
- Cost of this PR
- $1.870
Published comments (8)
Pagination hides custom group members beyond the first 50 — Update that consumer to fetch subsequent pages, or preserve the endpoint's complete-list behavior for custom groups. **Also found in:** - `app/assets/javascripts/discourse/routes/group-members.js.es6:8-11`
Removing a member leaves their primary group pointing to the removed group — `users.primary_group_id` becomes stale because `group.users.delete` bypasses the cleanup in `Group.destroy_deletions`. Clear the removed user's primary group when it matches this group, within the same transaction.
Adding an existing group member violates the unique membership index — Clicking Add again can raise a database exception because `Group.add` inserts another membership against the unique `(group_id, user_id)` index. Check `group.users.exists?` before adding each user so repeated submissions succeed.
Stale member responses can overwrite the latest group page or refresh — Out-of-order responses let `self.setProperties` replace the latest member page or membership refresh with stale data. Track a request sequence token for each group and apply a response only if it belongs to the latest request.
Automatic-group removal test does not verify membership is preserved — A `remove_member` implementation that deletes membership before returning 422 would still pass because this test checks only `response.status` without establishing membership. Create an automatic group with a real member, attempt removal, and assert both rejection and preserved membership.
Automatic-group addition test does not verify membership stays unchanged — Because `add_members` skips unresolved usernames, using an uncreated `l77t` and checking only `response.status` cannot detect membership changes before rejection. Create a real nonmember, submit that user's username, and assert both the 422 response and continued absence from the group.
Exact multiples of the page limit create an extra empty page — With 50 members and a limit of 50, `totalPages` becomes 2, enabling navigation to an empty page. Use `Math.ceil` instead of `Math.floor` plus one to count only populated pages.
Member pagination can remain on an empty page after membership shrinks — Removing the last member on a page can leave `removeMember` displaying an empty page because `Math.min` uses stale `user_count` and permits `offset` equal to the total. Clamp `offset` to the last nonempty page using the updated total, and refetch when necessary.