Amazon Ergo 1.0 · Balanced
fix-proper-handling-of-group-memberships-discourse-cursor
Discourse · Ruby · L · 300–799 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Opus 5.5.
- Gold bugs found
- 4 of 13
- Comments published
- 4
- Comments matching a bug
- 4
- Comments not matching
- 0
- Cost of this PR
- $1.915
Published comments (4)
Regular group member lists are truncated without pagination controls — Regular groups with more than 50 members lose access to the rest of their roster because `group/members.hbs` and `group-members.js.es6` render only `members` without pagination. Apply `limit`/`offset` only when `group.automatic?` so regular groups return their full member list.
remove_member passes an integer to group.users.delete — The endpoint returns 500 because Rails 4.1 collection associations require `User` objects, so the integer argument raises `ActiveRecord::AssociationTypeMismatch`. Pass `User.find(user_id)` to `group.users.delete`.
Adding existing group members raises a duplicate record error — Re-adding a member or repeating a username attempts a duplicate `group_users` insert, raising `RecordNotUnique` and returning 500 instead of a successful no-op. Skip IDs already in `group.user_ids`, then append each added user's ID so repeated usernames are also ignored.
totalPages overcounts when user_count is an exact multiple of limit — Exact multiples report an extra page, so `showingLast` stays false and `next()` advances `offset` to `user_count`, leaving the admin on an empty page. Use `Math.ceil(user_count / limit)` in `totalPages`, keeping the existing zero guard.