Claude Opus 5.5 · 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
3 of 10
Comments published
4
Comments matching a bug
3
Comments not matching
1
Cost of this PR
$2.591

Published comments (4)

highbugapp/assets/javascripts/discourse/routes/group-members.js.es6:8-11

Public group members page shows only the first 50 members — `findMembers` sends the default `limit: 50` and `members.hbs` has no next/previous controls, so larger groups lose members the server used to return in full. Add pagination or infinite loading to the public members page.

mediumbugapp/controllers/admin/groups_controller.rb:71-75

Adding an existing member raises RecordNotUnique and aborts the batch — `users.push` violates the unique index on `group_users(group_id, user_id)`, so the request fails with a 500 (`RecordNotUnique`) and the remaining usernames are never added. Skip existing members, e.g. `next if group.users.exists?(user.id)`, before calling `group.add`.

mediumbugspec/controllers/admin/groups_controller_spec.rb:114-117

remove_member spec sends PUT although the route is DELETE only — Controller specs skip verb routing, so this tests a request no client can send and misses the DELETE path the UI uses (`delete "members" => "groups#remove_member"`). Use `xhr :delete` to match the route and the sibling test.

mediumbugapp/assets/javascripts/admin/controllers/admin-group.js.es6:11-14

totalPages overcounts by one when user_count is a multiple of limit — On the real last page `showingLast` is false, so `next` sets `offset` to `user_count` and loads an empty member list (e.g. 50 members with `limit` 50 gives 2 pages). Replace `Math.floor(user_count / limit) + 1` with `Math.ceil(user_count / limit)`.

Gold bugs found (3)

mediumThe admin group pager computes total pages as floor(user_count / limit) + 1, so when the member count is an exact multiple of the limit it shows an extra page and Next navigates to an empty member list.
highThe public members endpoint now always caps results at 50 per page, but the public group members page has no pagination, so groups with more than 50 members are silently truncated for users.
mediumAdmin add_members pushes every username into group.users without skipping existing members, so adding someone already in the group hits the unique group_users index, returns a 500 and leaves earlier users partially added.

Gold bugs missed (7)

mediumPaging actions fire overlapping member requests and each response unconditionally overwrites offset and members, so a stale response arriving last can revert the list to an earlier page.
mediumCreating a group ignores the alias_level the admin selected, saving only name and visibility, so new groups keep the default alias level.
mediumRemoving a member deletes the membership row directly and skips clearing the user's primary_group_id, so a removed user can keep this group as their primary group.
mediumGroup member pagination is off by one when user_count is a multiple of limit: Next moves to offset == user_count and shows an empty page.
mediumAdmin remove_member deletes memberships with group.users.delete, which skips GroupUser callbacks, so the cached groups.user_count is never decremented and stays inflated.
mediumThe public group members endpoint takes `limit` from params with no upper bound or positivity check, letting a visitor request huge pages or trigger a 500 with a negative limit.
mediumAdmin remove_member calls group.users.delete with a raw integer id, which raises RecordNotFound (404/500) when the user is not or no longer a member, e.g. on concurrent removal.