crbench//

← all cases

FIX: proper handling of group memberships

Tier 2 medium ruby · local · real merged PR from ai-code-review-evaluation/discourse-graphite #8

Ground-truth defects

d2 · other · low
In the next action, capping the next offset at user_count can produce an empty page (e.g., total equal to limit results in offset == total, showing 2/2 with no members). This can cause confusing UX on the last page.
d3 · correctness · medium
`remove_member` deletes the association with `group.users.delete(user_id)`, which for a has_many-through with no `:dependent` resolves to a raw `delete_all` and never instantiates the join model, so the `counter_cache` on GroupUser never decrements. The sibling add path uses `group.add(user)`, which does instantiate and increments, so `groups.user_count` drifts upward monotonically and is rendered to admins and returned by the group endpoint.

The change under review

diff (truncated — full diff)
diff --git a/app/assets/javascripts/admin/controllers/admin-group.js.es6 b/app/assets/javascripts/admin/controllers/admin-group.js.es6
index 10cee82d99..6bd8eda6bf 100644
--- a/app/assets/javascripts/admin/controllers/admin-group.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-group.js.es6
@@ -1,34 +1,69 @@
 export default Em.ObjectController.extend({
   needs: ['adminGroups'],
-  members: null,
   disableSave: false,
+  usernames: null,
+
+  currentPage: function() {
+    if (this.get("user_count") == 0) { return 0; }
+    return Math.floor(this.get("offset") / this.get("limit")) + 1;
+  }.property("limit", "offset", "user_count"),
+
+  totalPages: function() {
+    if (this.get("user_count") == 0) { return 0; }
+    return Math.floor(this.get("user_count") / this.get("limit")) + 1;
+  }.property("limit", "user_count"),
+
+  showingFirst: Em.computed.lte("currentPage", 1),
+  showingLast: Discourse.computed.propertyEqual("currentPage", "totalPages"),
 
   aliasLevelOptions: function() {
     return [
-      { name: I18n.t("groups.alias_levels.nobody"), value: 0},
-      { name: I18n.t("groups.alias_levels.mods_and_admins"), value: 2},
-      { name: I18n.t("groups.alias_levels.members_mods_and_admins"), value: 3},
-      { name: I18n.t("groups.alias_levels.everyone"), value: 99}
+      { name: I18n.t("groups.alias_levels.nobody"), value: 0 },
+      { name: I18n.t("groups.alias_levels.mods_and_admins"), value: 2 },
+      { name: I18n.t("groups.alias_levels.members_mods_and_admins"), value: 3 },
+      { name: I18n.t("groups.alias_levels.everyone"), value: 99 }
     ];
   }.property(),
 
-  usernames: function(key, value) {
-    var members = this.get('members');
-    if (arguments.length > 1) {
-      this.set('_usernames', value);
-    } else {
-      var usernames;
-      if(members) {
-        usernames = members.map(function(user) {
-          return user.get('username');
-        }).join(',');
-      }
-      this.set('_usernames', usernames);
-    }
-    return this.get('_usernames');
-  }.property('members.@each.username'),
-
   actions: {
+    next: function() {
+      if (this.get("showingLast")) { return; }
+
+      var group = this.get("model"),
+          offset = Math.min(group.get("offset") + group.get("limit"), group.get("user_count"));
+
+      group.set("offset", offset);
+
+      return group.findMembers();
+    },
+
+    previous: function() {
+      if (this.get("showingFirst")) { return; }
+
+      var group = this.get("model"),
+          offset = Math.max(group.get("offset") - group.get("limit"), 0);
+
+      group.set("offset", offset);
+
+      return group.findMembers();
+    },
+
+    removeMember: function(member) {
+      var self = this,
+          message = I18n.t("admin.groups.delete_member_confirm", { username: member.get("username"), group: this.get("name") });
+      return bootbox.confirm(message, I18n.t("no_value"), I18n.t("yes_value"), function(confirm) {
+        if (confirm) {
+          self.get("model").removeMember(member);
+        }
+      });
+    },
+
+    addMembers: function() {
+      // TODO: should clear the input
+      if (Em.isEmpty(this.get("usernames"))) { return; }
+      this.get("model").addMembers(this.get("usernames"));
+    },
+
     save: function() {
       var self = this,
           group = this.get('model');
@@ -37,9 +72,9 @@ export default Em.ObjectController.extend({
 
       var promise;
       if (group.get('id')) {
-        promise = group.saveWithUsernames(this.get('usernames'));
+        promise = group.save();
       } else {
-        promise = group.createWithUsernames(this.get('usernames')).then(function() {
+        promise = group.create().then(function() {
           var groupsController = self.get('controllers.adminGroups');
           groupsController.addObject(group);
         });
diff --git a/app/assets/javascripts/admin/routes/admin_group_route.js b/app/assets/javascripts/admin/routes/admin_group_route.js
index 3de37b38e4..89388e1c32 100644
--- a/app/assets/javascripts/admin/routes/admin_group_route.js
+++ b/app/assets/javascripts/admin/routes/admin_group_route.js
@@ -8,16 +8,10 @@ Discourse.AdminGroupRoute = Discourse.Route.extend({
     return group;
   },
 
-  afterModel: function(model) {
-    var self = this;
-    return model.findMembers().then(function(members) {
-      self.set('_members', members);
-    });
-  },
-
   setupController: function(controller, model) {
-    controller.set('model', model);
-    controller.set('members', this.get('_members'));
+    controller.set("model", model);
+    model.findMembers();
   }
+
 });
 
diff --git a/app/assets/javascripts/admin/templates/group.hbs b/app/assets/javascripts/admin/templates/group.hbs
index e37eb39a7d..03d9d697e6 100644
--- a/app/assets/javascripts/admin/templates/group.hbs
+++ b/app/assets/javascripts/admin/templates/group.hbs
@@ -1,29 +1,53 @@
-{{#if automatic}}
-  <h3>{{name}}</h3>
-{{else}}
-  {{text-field value=name placeholderKey="admin.groups.name_placeholder"}}
-{{/if}}
+<form class="form-horizontal">
 
-<div class="control-group">
-  <label class="control-label">{{i18n 'admin.groups.group_members'}}</label>
-  <div class="controls">
-    {{user-selector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" disabled=automatic}}
+  <div>
+    {{#if automatic}}
+      <h3>{{name}}</h3>
+    {{else}}
+      <label for="name">{{i18n 'admin.groups.name'}}</label>
+      {{text-field name="name" value=name placeholderKey="admin.groups.name_placeholder"}}
+    {{/if}}
   </div>
-</div>
-<div class="control-group">
-  <div class="controls">
-    {{input type="checkbox" checked=visible}} {{i18n 'groups.visible'}}
+
+  {{#if id}}
+    <div>
+      <label>{{i18n 'admin.groups.group_members'}} ({{user_count}})</label>
+      <div>
+        <a {{bind-attr class=":previous showingFirst:disabled"}} {{action "previous"}}>{{fa-icon "fast-backward"}}</a>
+        {{currentPage}}/{{totalPages}}
+        <a {{bind-attr class=":next showingLast:disabled"}} {{action "next"}}>{{fa-icon "fast-forward"}}</a>
+      </div>
+      <div class="ac-wrap clearfix">
+        {{each member in members itemView="group-member"}}
+      </div>
+    </div>
+
+    {{#unless automatic}}
+      <div>
+        <label for="user-selector">{{i18n 'admin.groups.add_members'}}</label>
+        {{user-selector usernames=usernames placeholderKey="admin.groups.selector_placeholder" id="user-selector"}}
+        <button {{action "addMembers"}} class='btn add'>{{fa-icon "plus"}} {{i18n 'admin.groups.add'}}</button>
+      </div>
+    {{/unless}}
+  {{/if}}
+
+  <div>
+    <label>
+      {{input type="checkbox" checked=visible}}
+      {{i18n 'groups.visible'}}
+    </label>
   </div>
-</div>
-<div class="control-group">
-  <label class="control-label">{{i18n 'groups.alias_levels.title'}}</label>
-  <div class="controls">
-    {{combo-box valueAttribute="value" value=alias_level content=aliasLevelOptions}}
+
+  <div>
+    <label for="alias">{{i18n 'groups.alias_levels.title'}}</label>
+    {{combo-box name="alias" valueAttribute="value" value=alias_level content=aliasLevelOptions}}
   </div>
-</div>
-<div class='controls'>
-  <button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn'>{{i18n 'admin.customize.save'}}</button>
-  {{#unless automatic}}
-    <button {{action "destroy"}} class='btn btn-danger'><i class="fa fa-trash-o"></i>{{i18n 'admin.customize.delete'}}</button>
-  {{/unless}}
-</div>
+
+  <div class='buttons'>
+    <button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button>
+    {{#unless automatic}}
+      <button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button>
+    {{/unless}}
+  </div>
+
+</form>
diff --git a/app/assets/javascripts/admin/templates/group_member.hbs b/app/assets/javascripts/admin/templates/group_member.hbs
new file mode 100644
index 0000000000..d94f2ebe85
--- /dev/null
+++ b/app/assets/javascripts/admin/templates/group_member.hbs
@@ -0,0 +1 @@
+{{avatar member imageSize="small"}} {{member.username}} {{#unless automatic}}<a class='remove' {{action "removeMember" member}}>{{fa-icon "times"}}</a>{{/unless}}
diff --git a/app/assets/javascripts/admin/views/group-member.js.es6 b/app/assets/javascripts/admin/views/group-member.js.es6
new file mode 100644
index 0000000000..7889fd59cf
--- /dev/null
+++ b/app/assets/javascripts/admin/views/group-member.js.es6
@@ -0,0 +1,4 @@
+export default Discourse.View.extend({
+  classNames: ["item"],
+  templateName: "admin/templates/group_member"
+});
diff --git a/app/assets/javascripts/discourse/models/group.js b/app/assets/javascripts/discourse/models/group.js
index 669c8f698f..94930b291e 100644
--- a/app/assets/javascripts/discourse/models/group.js
+++ b/app/assets/javascripts/discourse/models/group.js
@@ -7,53 +7,80 @@
   @module Discourse
 **/
 Discourse.Group = Discourse.Model.extend({
+  limit: 50,
+  offset: 0,
+  user_count: 0,
 
   userCountDisplay: function(){
     var c = this.get('user_count');
     // don't display zero its ugly
-    if(c > 0) {
-      return c;
-    }
+    if (c > 0) { return c; }
   }.property('user_count'),
 
   findMembers: function() {
-    if (Em.isEmpty(this.get('name'))) { return Ember.RSVP.resolve([]); }
+    if (Em.isEmpty(this.get('name'))) { return ; }
 
-    return Discourse.ajax('/groups/' + this.get('name') + '/members').then(function(result) {
-      return result.map(function(u) { return Discourse.User.create(u) });
+    var self = this, offset = Math.min(this.get("user_count"), Math.max(this.get("offset"), 0));
+
+    return Discourse.ajax('/groups/' + this.get('name') + '/members.json', {
+      data: {
+        limit: this.get("limit"),
+        offset: offset
+      }
+    }).then(function(result) {
+      self.setProperties({
+        user_count: result.meta.total,
+        limit: result.meta.limit,
+        offset: result.meta.offset,
+        members: result.members.map(function(member) { return Discourse.User.create(member); })
+      });
     });
   },
 
-  destroy: function(){
-    if(!this.get('id')) return;
-    return Discourse.ajax("/admin/groups/" + this.get('id'), {type: "DELETE"});
+  removeMember: function(member) {
+    var self = this;
+    return Discourse.ajax('/admin/groups/' + this.get('id') + '/members.json', {
+      type: "DELETE",
+      data: { user_id: member.get("id") }
+    }).then(function() {
+      // reload member list
+      self.findMembers();
+    });
   },
 
-  asJSON: function() {
-    return { group: {
-             name: this.get('name'),
-             alias_level: this.get('alias_level'),
-             visible: !!this.get('visible'),
-             usernames: this.get('usernames') } };
+  addMembers: function(usernames) {
+    var self = this;
+    return Discourse.ajax('/admin/groups/' + this.get('id') + '/members.json', {
+      type: "PUT",
+      data: { usernames: usernames }
+    }).then(function() {
+      // reload member list
+      self.findMembers();
+    })
   },
 
-  createWithUsernames: function(usernames){
-    var self = this,
-        json = this.asJSON();
-    json.group.usernames = usernames;
+  asJSON: function() {
+    return {
+      name: this.get('name'),
+      alias_level: this.get('alias_level'),
+      visible: !!this.get('visible')
+    };
+  },
 
-    return Discourse.ajax("/admin/groups", {type: "POST", data: json}).then(function(resp) {
+  create: function(){
+    var self = this;
+    return Discourse.ajax("/admin/groups", { type: "POST", data: this.asJSON() }).then(function(resp) {
       self.set('id', resp.basic_group.id);
     });
   },
 
-  saveWithUsernames: function(usernames){
-    var json = this.asJSON();
-    json.group.usernames = usernames;
-    return Discourse.ajax("/admin/groups/" + this.get('id'), {
-      type: "PUT",
-      data: json
-    });
+  save: function(){
+    return Discourse.ajax("/admin/groups/" + this.get('id'), { type: "PUT", data: this.asJSON() });
+  },
+
+  destroy: function(){
+    if (!this.get('id')) { return };
+    return Discourse.ajax("/admin/groups/" + this.get('id'), {type: "DELETE"});
   },
 
   findPosts: function(opts) {
diff --git a/app/assets/javascripts/discourse/routes/group-members.js.es6 b/app/assets/javascripts/discourse/routes/group-members.js.es6
index b95fdfd88b..e6b207fc43 100644
--- a/app/assets/javascripts/discourse/routes/group-members.js.es6
+++ b/app/assets/javascripts/discourse/routes/group-members.js.es6
@@ -5,17 +5,10 @@ export default Discourse.Route.extend(ShowFooter, {
     return this.modelFor('group');
   },
 
-  afterModel: function(model) {
-    var self = this;
-    return model.findMembers().then(function(result) {
-      self.set('_members', result);
-    });
-  },
-
-  setupController: function(controller) {
-    controller.set('model', this.get('_members'));
+  setupController: function(controller, model) {
     this.controllerFor('group').set('showing', 'members');
+    controller.set("model", model);
+    model.findMembers();
   }
 
 });
-
diff --git a/app/assets/javascripts/discourse/templates/components/admin-group-selector.hbs b/app/assets/javascripts/discourse/templates/components/admin-group-selector.hbs
index f897810ab9..4856de5179 100644
--- a/app/assets/javascripts/discourse/templates/components/admin-group-selector.hbs
+++ b/app/assets/javascripts/discourse/templates/components/admin-group-selector.hbs
@@ -1,3 +1 @@
-
 <input type="text">
-
diff --git a/app/assets/javascripts/discourse/templates/group/members.hbs b/app/assets/javascripts/discourse/templates/group/members.hbs
index 6ac492ea39..16728d740e 100644
--- a/app/assets/javascripts/discourse/templates/group/members.hbs
+++ b/app/assets/javascripts/discourse/templates/group/members.hbs
@@ -3,7 +3,7 @@
     <tr>
       <th colspan="3" class="seen">{{i18n 'last_seen'}}</th>
     </tr>
-  {{#each m in model}}
+  {{#each m in members}}
   <tr>
       <td class='avatar'>
         {{avatar m imageSize="large"}}
diff --git a/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs b/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs
index cf42416338..eea69be0b8 100644
--- a/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs
+++ b/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs
@@ -2,19 +2,21 @@
   <ul>
     {{#each options.users}}
       <li>
-      <a href='#'>{{avatar this imageSize="tiny"}}
-        <span class='username'>{{this.username}}</span>
-        <span class='name'>{{this.name}}</span></a>
+        <a href='#'>{{avatar this imageSize="tiny"}}
+          <span class='username'>{{this.username}}</span>
+          <span class='name'>{{this.name}}</span>
+        </a>
       </li>
     {{/each}}
     {{#if options.groups}}
       {{#if options.users}}<hr>{{/if}}
       {{#each options.groups}}
         <li>
-        <a href=''><i class='icon-group'></i>
-          <span class='username'>{{this.name}}</span>
-          <span class='name'>{{max-usernames usernames max="3"}}</span>
-        </a>
+          <a href=''>
+            <i class='icon-group'></i>
+            <span class='username'>{{this.name}}</span>
+            <span class='name'>{{max-usernames usernames max="3"}}</span>
+          </a>
         </li>
       {{/each}}
     {{/if}}
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss
index 86b1d81238..3e71449fe1 100644
--- a/app/assets/stylesheets/common/admin/admin_base.scss
+++ b/app/assets/stylesheets/common/admin/admin_base.scss
@@ -161,6 +161,26 @@ td.flaggers td {
   }
 }
 
+.groups, .badges {
+  .form-horizontal {
+    label {
+      font-weight: bold;
+    }
+
+    & > div {
+      margin-top: 10px;
+    }
+
+    input, textarea, select {
+      width: 350px;
+    }
+
+    input[type="checkbox"] {
+      width: 20px;
+    }
+  }
+}
+
 .site-settings-nav {
   width: 18.018%;
   margin-top: 30px;
@@ -378,25 +398,10 @@ section.details {
   }
 
   .form-horizontal {
-    label {
-      font-weight: bold;
-    }
-    & > div {
-      margin-top: 10px;
-    }
     .delete-link {
       margin-left: 15px;
       margin-top: 5px;
     }
-
-    input, textarea, select {
-      width: 350px;
-    }
-
-    input[type="checkbox"] {
-      width: 20px;
-    }
-
     textarea {
       height: 200px;
     }
@@ -454,6 +459,26 @@ section.details {
   }
 }
 
+// Groups area
+.groups {
+  .ac-wrap {
+    width: 100% !important;
+    .item {
+      width: 190px;
+      margin-right: 0 !important;
+    }
+  }
+  .next, .previous {
+    color: #333 !important;
+    &.disabled {
+      color: #aaa !important;
+    }
+  }
+  .btn.add {
+    margin-top: 7px;

Leaderboard for this case

medium · 3 of 9 bots fully caught it (33% solve rate) · 61% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 2/2 100.0% 6 0
2 Drape (Deep Review) solved 2/2 100.0% 6 0
3 Mjolnir (Sonnet 5.5) solved 2/2 100.0% 6 0
4 cursor partial 1/2 33.3% 4 0
5 Drape (Review) partial 1/2 33.3% 9 0
6 Mjolnir (Opus 5.5) partial 1/2 33.3% 7 0
7 Cubic partial 1/2 33.3% 8 2
8 greptile partial 1/2 33.3% 4 2
9 qodo miss 0/2 0.0% 0 0

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ exact
d3 medium ✓ exact
valid · impact medium
Group#add is `self.users.push(user)`, which on a persisted group inserts at once. group_users has a unique index on [group_id, user_id] (db/migrate/20130416004933_group_users.rb), so adding a username that is already a member raises RecordNotUnique (a 500), and users pushed earlier in the same request stay saved. The new add_members endpoint does no membership check, unlike the old usernames= diff path the UI used. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · impact medium
The citation path is slightly off, but the real file (group-members.js.es6) is in the diff. Before, non-automatic groups returned all members; now every group is capped at 50 by default. The public members template only loops over `members` and has no pagination controls, so a group with more than 50 members only ever shows the first 50. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Unvalidated limit and offset now apply to all groups. A negative LIMIT or OFFSET makes PostgreSQL raise an error, so non-automatic groups that used to ignore these params can now return a 500. The huge-limit part was already possible for automatic groups before this change, so the impact is low. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact low
The first claim (callers chaining .then on undefined) is not borne out: none of the shown callers chain .then on findMembers. The second claim does hold: addMembers never clears usernames, so pressing Add again resubmits the same usernames and hits the duplicate-insert 500 from finding 0. [grounded: diff] [consensus 3/3: valid=3]
raw comments (6)
app/controllers/admin/groups_controller.rb:73
add_members calls group.add(user) (users.push) for every username without checking whether the user is already in the group. group_users has a UNIQUE index on (group_id, user_id), so adding a username that is already a member raises ActiveRecord::RecordNotUnique and the request fails with a 500. Any members added earlier in the same request have already been saved, so the add can partly succeed. The old usernames= setter avoided this by diffing against current members first.
app/controllers/admin/groups_controller.rb:89
remove_member uses group.users.delete(user_id). On a has_many :through this deletes the group_users join row directly, skipping GroupUser callbacks and the existing Group#remove path (which destroys each GroupUser). The user_count counter_cache on GroupUser may therefore not be decremented, leaving group.user_count stale. That value now drives the member total and the pagination in the UI. Use group.remove(User.find(user_id)) or destroy the GroupUser instead.
app/controllers/groups_controller.rb:22
The public /groups/:name/members endpoint now returns at most 50 members by default for every group; before, non-automatic groups returned all members. The public group members page (routes/group-members.js.es6, templates/group/members.hbs) has no pagination controls, so a group with more than 50 members only ever shows the first 50.
app/controllers/groups_controller.rb:23
limit and offset come straight from the user and are not validated. A negative offset or limit makes PostgreSQL raise an error, giving a 500. An arbitrarily large limit lets any visitor load every member of large automatic groups in one request; before, automatic groups were capped by default.
app/assets/javascripts/admin/controllers/admin-group.js.es6:13
totalPages = floor(user_count / limit) + 1 overcounts when user_count is an exact multiple of limit. For example, 50 members with limit 50 shows '1/2', and clicking next moves offset to 50 and loads an empty page. It should be Math.ceil(user_count / limit).
app/assets/javascripts/discourse/models/group.js:22
findMembers now returns undefined instead of a promise when the name is empty, which breaks any caller that chains .then() on it. Separately, addMembers in the admin controller never clears the usernames input, so pressing Add again re-submits the same usernames. Combined with the missing duplicate check on the server, that resubmission triggers the unique-constraint 500.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✗ —
valid · impact low
The citation-check misses the .es6 extension, but the code is in the diff. Example: 51 members on 2 pages. Removing the only member on page 2 reloads with offset min(51,50)=50, which returns an empty list. The page counter still shows 2/2, so the admin is left on an empty page. [grounded: diff] [consensus 5/5: valid=5]
valid · matches d2 · impact low
valid · impact low
The new <form> wrapper allows implicit submission. For an existing non-automatic group, the first default (submit) button in the form is the addMembers button, so pressing Enter in a field clicks it instead of saving. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
User-supplied limit/offset now apply to all groups with no clamping. A negative value makes Postgres raise an error. The old code already did this for automatic groups, and non-automatic groups used to return every member, so the impact is small. [grounded: diff] [consensus 5/5: valid=5]
invalid
The old create action also ignored alias_level: it set only name, usernames and visible, while the old asJSON already sent alias_level. This gap existed before the change. [invalid: introduced=no] [consensus 5/5: invalid=5]
valid · impact low
Before the change, the members promise was returned from afterModel, so a failed request blocked the route transition. Now it is fire-and-forget in setupController, so a rejection goes unhandled and the member list stays empty with no error shown. [grounded: diff] [consensus 5/5: valid=5]
invalid
The keyword form `each member in members` keeps the parent context (the group controller) and exposes the item as `member`. The template's own use of `member.username` confirms this, so `automatic` resolves against the group. [invalid: contradiction] [consensus 5/5: invalid=5]
valid · impact low
The labels use for="name" and for="alias", but the controls only get name attributes, not matching ids. Clicking a label therefore does not focus its control. [grounded: diff] [consensus 5/5: valid=5]
raw comments (9)
app/assets/javascripts/admin/controllers/admin-group.js.es6:56
<!-- cubic:v=e4b15a0b-5ca7-41c4-92d7-95c6922b7ce1 --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":9} --> P2: When an admin removes the only member on the last page, this refresh keeps the old offset after the total shrinks, leaving the UI on an empty page. Clamp the offset to the new last page before reloading members. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/admin/controllers/admin-group.js.es6, line 56: <comment>When an admin removes the only member on the last page, this refresh keeps the old offset after the total shrinks, leaving the UI on an empty page. Clamp the offset to the new last page before reloading members.</comment> <file context> @@ -1,34 +1,69 @@ + message = I18n.t("admin.groups.delete_member_confirm", { username: member.get("username"), group: this.get("name") }); + return bootbox.confirm(message, I18n.t("no_value"), I18n.t("yes_value"), function(confirm) { + if (confirm) { + self.get("model").removeMember(member); + } + }); </file context> ``` </details>
app/assets/javascripts/admin/controllers/admin-group.js.es6:13
<!-- cubic:v=e72a9466-34ad-4ece-a737-166a2504900e --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":10} --> P2: When `user_count` is an exact multiple of `limit`, `totalPages` includes a nonexistent extra page and `next` loads an empty member list. Use a ceiling calculation for the page count. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/admin/controllers/admin-group.js.es6, line 13: <comment>When `user_count` is an exact multiple of `limit`, `totalPages` includes a nonexistent extra page and `next` loads an empty member list. Use a ceiling calculation for the page count.</comment> <file context> @@ -1,34 +1,69 @@ + + totalPages: function() { + if (this.get("user_count") == 0) { return 0; } + return Math.floor(this.get("user_count") / this.get("limit")) + 1; + }.property("limit", "user_count"), + </file context> ``` </details> ```suggestion return Math.ceil(this.get("user_count") / this.get("limit")); ```
app/assets/javascripts/admin/templates/group.hbs:1
<!-- cubic:v=d6b30b31-4ce6-43d7-bca7-428ebc8e82ed --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":8} --> P2: When editing an existing group, pressing Enter in the name field implicitly invokes `addMembers` instead of saving. Mark non-save buttons as `type="button"` and handle the form submit with the `save` action. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/admin/templates/group.hbs, line 1: <comment>When editing an existing group, pressing Enter in the name field implicitly invokes `addMembers` instead of saving. Mark non-save buttons as `type="button"` and handle the form submit with the `save` action.</comment> <file context> @@ -1,29 +1,53 @@ -{{else}} - {{text-field value=name placeholderKey="admin.groups.name_placeholder"}} -{{/if}} +<form class="form-horizontal"> -<div class="control-group"> </file context> ``` </details>
app/controllers/groups_controller.rb:23
<!-- cubic:v=091d7f8d-9450-4329-b931-18f8ab1fcd68 --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":9} --> P2: When a caller supplies a very large or negative `limit`/`offset`, this public action passes it directly to ActiveRecord and materializes the result, allowing an effectively unbounded or invalid member query. Clamp `offset` to zero and constrain `limit` to a positive maximum before building the relation. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/controllers/groups_controller.rb, line 22: <comment>When a caller supplies a very large or negative `limit`/`offset`, this public action passes it directly to ActiveRecord and materializes the result, allowing an effectively unbounded or invalid member query. Clamp `offset` to zero and constrain `limit` to a positive maximum before building the relation.</comment> <file context> @@ -19,26 +19,29 @@ def posts - end - - render_serialized(members.to_a, GroupUserSerializer) + limit = (params[:limit] || 50).to_i + offset = params[:offset].to_i + </file context> ``` </details> ```suggestion limit = [[(params[:limit] || 50).to_i, 1].max, 100].min offset = [params[:offset].to_i, 0].max ```
app/assets/javascripts/discourse/models/group.js:72
<!-- cubic:v=22836f00-f93d-43a3-85d8-954e5aeb9bb8 --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":9} --> P2: When creating a group with a non-default `alias_level`, `create()` sends the value but `Admin::GroupsController#create` never assigns it, so the persisted group always uses the default alias level. Handle `alias_level` in the create path before relying on this payload. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/discourse/models/group.js, line 72: <comment>When creating a group with a non-default `alias_level`, `create()` sends the value but `Admin::GroupsController#create` never assigns it, so the persisted group always uses the default alias level. Handle `alias_level` in the create path before relying on this payload.</comment> <file context> @@ -7,53 +7,80 @@ - return Discourse.ajax("/admin/groups", {type: "POST", data: json}).then(function(resp) { + create: function(){ + var self = this; + return Discourse.ajax("/admin/groups", { type: "POST", data: this.asJSON() }).then(function(resp) { self.set('id', resp.basic_group.id); }); </file context> ``` </details>
app/assets/javascripts/discourse/routes/group-members.js.es6:11
<!-- cubic:v=74961657-3f33-4a33-a43a-2c65786a848a --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":9} --> P2: When the members request fails, this fire-and-forget call lets the route transition complete and leaves the members view empty. Keep the fetch in `afterModel` or otherwise handle its rejection so the failure is surfaced. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/discourse/routes/group-members.js.es6, line 11: <comment>When the members request fails, this fire-and-forget call lets the route transition complete and leaves the members view empty. Keep the fetch in `afterModel` or otherwise handle its rejection so the failure is surfaced.</comment> <file context> @@ -5,17 +5,10 @@ export default Discourse.Route.extend(ShowFooter, { + setupController: function(controller, model) { this.controllerFor('group').set('showing', 'members'); + controller.set("model", model); + model.findMembers(); } </file context> ``` </details>
app/assets/javascripts/admin/templates/group_member.hbs:1
<!-- cubic:v=d6c3a67b-0079-4b2e-ae2d-703730f04f11 --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":5} --> P2: The `automatic` guard in the member item template checks a property of the group, but this template's context is the individual member (a Discourse.User), which has no `automatic` field. Whether it resolves to the group's `automatic` depends on Ember's controller fallback from the item view; if it resolves against the member it is always falsy and the remove link is shown even for automatic groups (e.g. staff/admins), letting an admin attempt removal there. Bind explicitly to the group's `automatic` (pass it in or reference the controller) so the guard reflects the actual automatic-group state rather than relying on the item-view context chain. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/admin/templates/group_member.hbs, line 1: <comment>The `automatic` guard in the member item template checks a property of the group, but this template's context is the individual member (a Discourse.User), which has no `automatic` field. Whether it resolves to the group's `automatic` depends on Ember's controller fallback from the item view; if it resolves against the member it is always falsy and the remove link is shown even for automatic groups (e.g. staff/admins), letting an admin attempt removal there. Bind explicitly to the group's `automatic` (pass it in or reference the controller) so the guard reflects the actual automatic-group state rather than relying on the item-view context chain.</comment> <file context> @@ -0,0 +1 @@ +{{avatar member imageSize="small"}} {{member.username}} {{#unless automatic}}<a class='remove' {{action "removeMember" member}}>{{fa-icon "times"}}</a>{{/unless}} </file context> ``` </details>
app/assets/javascripts/admin/templates/group.hbs:7
<!-- cubic:v=66bce953-6f9d-491f-bd35-730658ba468f --> <!-- cubic:review-run=95df692e-c6c9-558e-954f-82b96481a7db --> <!-- metadata:{"confidence":9} --> P3: The new `for` attributes do not identify either associated control, so clicking these labels cannot focus their fields. Give the text field and combo box matching `id="name"` and `id="alias"` attributes. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At app/assets/javascripts/admin/templates/group.hbs, line 7: <comment>The new `for` attributes do not identify either associated control, so clicking these labels cannot focus their fields. Give the text field and combo box matching `id="name"` and `id="alias"` attributes.</comment> <file context> @@ -1,29 +1,53 @@ + {{#if automatic}} + <h3>{{name}}</h3> + {{else}} + <label for="name">{{i18n 'admin.groups.name'}}</label> + {{text-field name="name" value=name placeholderKey="admin.groups.name_placeholder"}} + {{/if}} </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **8 issues found** across 16 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="app/assets/javascripts/admin/controllers/admin-group.js.es6"> <violation number="1" location="app/assets/javascripts/admin/controllers/admin-group.js.es6:13"> P2: When `user_count` is an exact multiple of `limit`, `totalPages` includes a nonexistent extra page and `next` loads an empty member list. Use a ceiling calculation for the page count.</violation> <violation number="2" location="app/assets/javascripts/admin/controllers/admin-group.js.es6:56"> P2: When an admin removes the only member on the last page, this refresh keeps the old offset after the total shrinks, leaving the UI on an empty page. Clamp the offset to the new last page before reloading members.</violation> </file> <file name="app/assets/javascripts/admin/templates/group.hbs"> <violation number="1" location="app/assets/javascripts/admin/templates/group.hbs:1"> P2: When editing an existing group, pressing Enter in the name field implicitly invokes `addMembers` instead of saving. Mark non-save buttons as `type="button"` and handle the form submit with the `save` action.</violation> <violation number="2" location="app/assets/javascripts/admin/templates/group.hbs:7"> P3: The new `for` attributes do not identify either associated control, so clicking these labels cannot focus their fields. Give the text field and combo box matching `id="name"` and `id="alias"` attributes.</violation> </file> <file name="app/controllers/groups_controller.rb"> <violation number="1" location="app/controllers/groups_controller.rb:22"> P2: When a caller supplies a very large or negative `limit`/`offset`, this public action passes it directly to ActiveRecord and materializes the result, allowing an effectively unbounded or invalid member query. Clamp `offset` to zero and constrain `limit` to a positive maximum before building the relation.</violation> </file> <file name="app/assets/javascripts/discourse/models/group.js"> <violation number="1" location="app/assets/javascripts/discourse/models/group.js:72"> P2: When creating a group with a non-default `alias_level`, `create()` sends the value but `Admin::GroupsController#create` never assigns it, so the persisted group always uses the default alias level. Handle `alias_level` in the create path before relying on this payload.</violation> </file> <file name="app/assets/javascripts/discourse/routes/group-members.js.es6"> <violation number="1" location="app/assets/javascripts/discourse/routes/group-members.js.es6:11"> P2: When the members request fails, this fire-and-forget call lets the route transition complete and leaves the members view empty. Keep the fetch in `afterModel` or otherwise handle its rejection so the failure is surfaced.</violation> </file> <file name="app/assets/javascripts/admin/templates/group_member.hbs"> <violation number="1" location="app/assets/javascripts/admin/templates/group_member.hbs:1"> P2: The `automatic` guard in the member item template checks a property of the group, but this template's context is the individual member (a Discourse.User), which has no `automatic` field. Whether it resolves to the group's `automatic` depends on Ember's controller fallback from the item view; if it resolves against the member it is always falsy and the remove link is shown even for automatic groups (e.g. staff/admins), letting an admin attempt removal there. Bind explicitly to the group's `automatic` (pass it in or reference the controller) so the guard reflects the actual automatic-group state rather than relying on the item-view context chain.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/35/ai_pr_review_github_delivery_494b3c64a186a570c74f035e2673611451363252e8f55e3724c422d4e7a74d1b?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F35)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_494b3c64a186a570c74f035e2673611451363252e8f55e3724c422d4e7a74d1b:6f8047d01ee19463b320e2ec82c46e93b3398c75:95df692e-c6c9-558e-954f-82b96481a7db -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✗ —
valid · matches d2 · impact low
valid · impact medium
The public members endpoint now always limits to 50, where before non-automatic groups returned every member. The public route only calls model.findMembers() and members.hbs iterates `members` with no pagination controls, so larger groups show a truncated list. The citation-check miss is only a wrong file extension: group-members.js.es6 exists and is in the diff. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
Example: with 51 members and offset 50, removing the last one reloads with offset min(51,50)=50. The server returns an empty members page with total 50, and the page stays on 2/2 showing an empty list. The new code does not step the offset back a page. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
Group#destroy_deletions (the old usernames= save path the admin UI used) cleared primary_group_id. The new remove_member uses group.users.delete, and GroupUser has no callback that resets primary_group_id, so removed users can keep a stale primary group. [grounded: diff] [consensus 5/5: valid=5]
raw comments (5)
app/assets/javascripts/admin/controllers/admin-group.js.es6:14
### Pagination counts an extra page **Medium Severity** <!-- DESCRIPTION START --> `totalPages` uses `Math.floor(user_count / limit) + 1`, which adds a phantom page whenever `user_count` is a multiple of `limit`. Combined with `next` capping `offset` at `user_count`, admins can advance onto an empty page (for example 50 members at limit 50 shows `1/2` and Next loads zero rows). <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: ab3de437-0786-4e90-b548-d797e058ed2f --> <!-- LOCATIONS START app/assets/javascripts/admin/controllers/admin-group.js.es6#L10-L14 app/assets/javascripts/admin/controllers/admin-group.js.es6#L28-L37 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`app/assets/javascripts/admin/controllers/admin-group.js.es6#L28-L37`](https://github.com/drape-io/crbench-cursor-2026-09/blob/00ec5d009ad3b233195000fe86f9758ec88dfda4/app/assets/javascripts/admin/controllers/admin-group.js.es6#L28-L37) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVkMWM4YTNmLWQwMDUtNDg0Yi04NjdhLThhM2Q3ZDY3YTA4NCIsImVuY3J5cHRpb25LZXkiOiI3aEZoSlUwZEZzOFpfV2xoLTdSenl4Y1RoMVJGN3dUdnBZbUtxR0tPc3FZIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVkMWM4YTNmLWQwMDUtNDg0Yi04NjdhLThhM2Q3ZDY3YTA4NCIsImVuY3J5cHRpb25LZXkiOiI3aEZoSlUwZEZzOFpfV2xoLTdSenl4Y1RoMVJGN3dUdnBZbUtxR0tPc3FZIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjozNiwiY29tbWl0U2hhIjoiMDBlYzVkMDA5YWQzYjIzMzE5NTAwMGZlODZmOTc1OGVjODhkZmRhNCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 00ec5d009ad3b233195000fe86f9758ec88dfda4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
app/controllers/groups_controller.rb:26
### Public members list silently truncated **High Severity** <!-- DESCRIPTION START --> `GroupsController#members` now always applies a default limit of 50 to every group, but the public members template and route have no pagination. Previously non-automatic groups returned all members and automatic groups defaulted to 200. Groups larger than 50 now show an incomplete list with no way to load the rest. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 814bec46-69bf-4e30-b6b9-118700c5e24b --> <!-- LOCATIONS START app/controllers/groups_controller.rb#L21-L26 app/assets/javascripts/discourse/templates/group/members.hbs#L5-L6 app/assets/javascripts/discourse/routes/group-members.js.es6#L7-L12 LOCATIONS END --> <details> <summary>Additional Locations (2)</summary> - [`app/assets/javascripts/discourse/templates/group/members.hbs#L5-L6`](https://github.com/drape-io/crbench-cursor-2026-09/blob/00ec5d009ad3b233195000fe86f9758ec88dfda4/app/assets/javascripts/discourse/templates/group/members.hbs#L5-L6) - [`app/assets/javascripts/discourse/routes/group-members.js.es6#L7-L12`](https://github.com/drape-io/crbench-cursor-2026-09/blob/00ec5d009ad3b233195000fe86f9758ec88dfda4/app/assets/javascripts/discourse/routes/group-members.js.es6#L7-L12) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjA4OWJkNWY4LTliZDItNDIzOS1hY2JkLWRiNjhjZjIxMmE4MyIsImVuY3J5cHRpb25LZXkiOiItZmJ5cFpieVJHR1lDVnY2UEVOaGR4VjZ0bVM5UDlTUzVnT25xb0FoOHZvIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjA4OWJkNWY4LTliZDItNDIzOS1hY2JkLWRiNjhjZjIxMmE4MyIsImVuY3J5cHRpb25LZXkiOiItZmJ5cFpieVJHR1lDVnY2UEVOaGR4VjZ0bVM5UDlTUzVnT25xb0FoOHZvIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjozNiwiY29tbWl0U2hhIjoiMDBlYzVkMDA5YWQzYjIzMzE5NTAwMGZlODZmOTc1OGVjODhkZmRhNCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 00ec5d009ad3b233195000fe86f9758ec88dfda4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
app/assets/javascripts/discourse/models/group.js:48
### Delete last member leaves empty page **Medium Severity** <!-- DESCRIPTION START --> `removeMember` reloads the current `offset` after a successful delete. If that was the last user on a later page, `offset` still equals the old page start (and `findMembers` clamps with `Math.min(user_count, offset)`, which does not move back a page). The admin list renders empty until Previous is clicked. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 824081b4-aaf1-4bdb-8cbd-77dfe543eccb --> <!-- LOCATIONS START app/assets/javascripts/discourse/models/group.js#L39-L48 app/assets/javascripts/discourse/models/group.js#L19-L37 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`app/assets/javascripts/discourse/models/group.js#L19-L37`](https://github.com/drape-io/crbench-cursor-2026-09/blob/00ec5d009ad3b233195000fe86f9758ec88dfda4/app/assets/javascripts/discourse/models/group.js#L19-L37) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMyNDdiYjM1LTdmZTMtNGMyOS1hZWMxLTUwNmMxNTkyZGIzNSIsImVuY3J5cHRpb25LZXkiOiJVM0pRNTNYSnFoRWNmRUxWSWxURjV3MnlTS2NIN010TjhWS1p3MEJTS3RNIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMyNDdiYjM1LTdmZTMtNGMyOS1hZWMxLTUwNmMxNTkyZGIzNSIsImVuY3J5cHRpb25LZXkiOiJVM0pRNTNYSnFoRWNmRUxWSWxURjV3MnlTS2NIN010TjhWS1p3MEJTS3RNIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjozNiwiY29tbWl0U2hhIjoiMDBlYzVkMDA5YWQzYjIzMzE5NTAwMGZlODZmOTc1OGVjODhkZmRhNCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 00ec5d009ad3b233195000fe86f9758ec88dfda4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
app/controllers/admin/groups_controller.rb:97
### Removal skips primary group cleanup **Low Severity** <!-- DESCRIPTION START --> `remove_member` deletes the join via `group.users.delete(user_id)` and never clears `primary_group_id`. The previous `usernames=` save path did that in `destroy_deletions`. Users removed from their primary group can keep a stale primary group title and association. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: cffc2c5d-6a21-4410-bfb6-3e20463a7246 --> <!-- LOCATIONS START app/controllers/admin/groups_controller.rb#L83-L97 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFjYzkyMGE3LTRjMmYtNDllMS1hMGYyLWU1MWM5ZWQ4Mjc5MiIsImVuY3J5cHRpb25LZXkiOiJUQkNwa3R4OXhPYzgzTVM5NGJMdzlZaVRtWEpFUDAycVpOQ19DQWt2M2ZJIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFjYzkyMGE3LTRjMmYtNDllMS1hMGYyLWU1MWM5ZWQ4Mjc5MiIsImVuY3J5cHRpb25LZXkiOiJUQkNwa3R4OXhPYzgzTVM5NGJMdzlZaVRtWEpFUDAycVpOQ19DQWt2M2ZJIiwiYnJhbmNoIjoidDItZGlzY291cnNlLWdyYXBoaXRlLTgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjozNiwiY29tbWl0U2hhIjoiMDBlYzVkMDA5YWQzYjIzMzE5NTAwMGZlODZmOTc1OGVjODhkZmRhNCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 00ec5d009ad3b233195000fe86f9758ec88dfda4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using high effort and found 4 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTozN2NhYjIzYy04ZWI0LTQ4MmUtOWMzNS0wYWJiYWMyNGE4ZTAiLCJlbmNyeXB0aW9uS2V5IjoiWnYtc3Vid2JMQnhkeVhyb3JqWndhQjA1VW9aRTAxQjRwcGtVbVVQZFJFRSIsImJyYW5jaCI6InQyLWRpc2NvdXJzZS1ncmFwaGl0ZS04IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 00ec5d009ad3b233195000fe86f9758ec88dfda4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ exact
d3 medium ✓ exact
valid · impact medium
The new add_members endpoint calls group.add(user) (users.push) for every username with no membership check. The unique index on (group_id, user_id) makes a duplicate insert raise, which returns a 500. The admin UI now uses this endpoint in place of the diffing usernames= path. [grounded: tree app/controllers/admin/groups_controller.rb] [consensus 3/3: valid=3]
valid · impact medium
The new remove_member only deletes the join row. GroupUser has no callback that clears primary_group_id, while the old usernames= path did clear it in destroy_deletions. [grounded: tree app/controllers/admin/groups_controller.rb] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · impact medium
findMembers now pages 50 at a time, and the public members.hbs template has no next/previous controls. Before this change, non-automatic groups returned all their members. The real file is group-members.js.es6, which is shown in the diff. [grounded: diff-section app/assets/javascripts/discourse/models/group.js] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact low
limit and offset are passed through to_i without bounds. A negative value makes Postgres raise, giving a 500. Before, this applied only to automatic groups; now it applies to every group. The large-limit part is weaker, because non-automatic groups already loaded all members before. [grounded: diff-section app/controllers/groups_controller.rb] [consensus 3/3: valid=3]
raw comments (6)
app/controllers/admin/groups_controller.rb:72
**Adding an existing member crashes the request** If any submitted username is already in the group, `group.add(user)` inserts a duplicate row and hits the unique (group_id, user_id) index. The request fails with a 500 and the remaining usernames are never processed. Skip users already in the group (e.g. `group.add(user) unless group.users.include?(user)`). ``` app/controllers/admin/groups_controller.rb:66 group = Group.find(params.require(:group_id).to_i) app/controllers/admin/groups_controller.rb:67 usernames = params.require(:usernames) app/controllers/admin/groups_controller.rb:69 return can_not_modify_automatic if group.automatic app/controllers/admin/groups_controller.rb:71 usernames.split(",").each do |username| app/models/group.rb:272 def add(user) app/models/group.rb:273 self.users.push(user) app/models/group.rb:274 end app/models/group_user.rb:18 # index_group_users_on_group_id_and_user_id (group_id,user_id) UNIQUE db/migrate/20130416004933_group_users.rb:9 add_index :group_users, [:group_id, :user_id], unique: true ```
app/controllers/admin/groups_controller.rb:90
**Removed member keeps group as primary group** `group.users.delete(user_id)` deletes only the join row. The old removal path also cleared the user's `primary_group_id`, so a removed user can keep the group as their primary group (flair/title). Also run `User.where(id: user_id, primary_group_id: group.id).update_all(primary_group_id: nil)`. ``` app/controllers/admin/groups_controller.rb:84 def remove_member app/controllers/admin/groups_controller.rb:85 group = Group.find(params.require(:group_id).to_i) app/controllers/admin/groups_controller.rb:86 user_id = params.require(:user_id).to_i app/controllers/admin/groups_controller.rb:88 return can_not_modify_automatic if group.automatic app/models/group.rb:286 # hack around AR app/models/group.rb:287 def destroy_deletions app/models/group.rb:288 if @deletions app/models/group.rb:289 @deletions.each do |gu| app/models/group.rb:290 gu.destroy app/models/group.rb:291 User.where('id = ? AND primary_group_id = ?', gu.user_id, gu.group_id).update_all 'primary_group_id = NULL' ```
app/controllers/admin/groups_controller.rb:90
**Group user_count not decremented on removal** `group.users.delete` on a has_many :through deletes the GroupUser rows with delete_all. That skips the `user_count` counter cache on GroupUser's belongs_to, so the stored count stays too high. Use `group.group_users.where(user_id: user_id).destroy_all` (or the existing `group.remove`). ``` app/controllers/admin/groups_controller.rb:90 group.users.delete(user_id) app/models/group_user.rb:2 belongs_to :group, counter_cache: "user_count" app/models/group.rb:8 has_many :users, through: :group_users app/models/group.rb:276 def remove(user) app/models/group.rb:277 self.group_users.where(user: user).each(&:destroy) app/models/group.rb:278 end ```
app/assets/javascripts/discourse/routes/group-members.js.es6:11
**Public members page only shows first 50** `findMembers` now fetches 50 members by default, but the public group members page has no paging controls. Members beyond the first 50 can't be seen there. Before, non-automatic groups listed all their members. Add paging (or load-more) to the public members page. ``` app/assets/javascripts/discourse/routes/group-members.js.es6:8 setupController: function(controller, model) { app/assets/javascripts/discourse/routes/group-members.js.es6:9 this.controllerFor('group').set('showing', 'members'); app/assets/javascripts/discourse/routes/group-members.js.es6:10 controller.set("model", model); app/assets/javascripts/discourse/routes/group-members.js.es6:11 model.findMembers(); app/assets/javascripts/discourse/templates/group/members.hbs:1 {{#if model}} app/assets/javascripts/discourse/templates/group/members.hbs:2 <table class='group-members'> app/assets/javascripts/discourse/templates/group/members.hbs:3 <tr> app/assets/javascripts/discourse/templates/group/members.hbs:4 <th colspan="3" class="seen">{{i18n 'last_seen'}}</th> app/assets/javascripts/discourse/templates/group/members.hbs:5 </tr> app/assets/javascripts/discourse/templates/group/members.hbs:6 {{#each m in members}} ```
app/assets/javascripts/admin/controllers/admin-group.js.es6:13
**Extra empty page when count divides evenly** When `user_count` is an exact multiple of `limit` (e.g. 50 members, limit 50), `totalPages` adds one page too many, so the pager shows "1/2" and Next loads an empty page. Use Math.ceil(user_count / limit). ``` app/assets/javascripts/admin/controllers/admin-group.js.es6:11 totalPages: function() { app/assets/javascripts/admin/controllers/admin-group.js.es6:12 if (this.get("user_count") == 0) { return 0; } app/assets/javascripts/admin/controllers/admin-group.js.es6:13 return Math.floor(this.get("user_count") / this.get("limit")) + 1; app/assets/javascripts/admin/controllers/admin-group.js.es6:14 }.property("limit", "user_count"), ```
app/controllers/groups_controller.rb:22
**Members endpoint accepts any limit/offset** `limit` and `offset` come straight from params with no bounds. A huge limit loads and serializes the whole group, and a negative value makes Postgres error with a 500. Clamp limit to e.g. 1..200 and offset to >= 0. ``` app/controllers/groups_controller.rb:22 limit = (params[:limit] || 50).to_i app/controllers/groups_controller.rb:23 offset = params[:offset].to_i app/controllers/groups_controller.rb:25 total = group.users.count app/controllers/groups_controller.rb:26 members = group.users.order(:username_lower).limit(limit).offset(offset) ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✗ —
valid · impact medium
Removing members used to go through usernames=/destroy_deletions, which also cleared primary_group_id. The new remove_member only deletes the join row, so a removed user can keep this group as their primary group. [grounded: tree app/controllers/admin/groups_controller.rb] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact low
limit and offset are taken from params with no bounds and now apply to every group. Postgres rejects a negative LIMIT or OFFSET, so the request returns a 500. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The public members route calls findMembers once and the model's default limit is 50. members.hbs has no paging controls. Before, non-automatic groups returned every member. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Example: user_count 51, offset 50; removing the only member on page 2 reloads with offset 50. The server returns no rows and the page shows 2/2 with an empty list. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
group.add pushes onto users without checking membership. group_users has a unique index on [group_id, user_id] (db/migrate/20130416004933_group_users.rb), so adding an existing member raises and returns a 500. The old usernames= only added the difference. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The usernames field is never cleared after a successful add (the TODO admits this), so clicking Add again resubmits the same names into the duplicate-member failure. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
params.require can return an Array or Hash (e.g. usernames[]=a), and calling split on it raises NoMethodError, giving a 500. Only admins can reach this endpoint, so impact is low. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Each response sets offset and members without checking whether a newer request is in flight. A late response from an earlier page click can overwrite the newer state. This is a real race but only matters with fast clicking. [grounded: diff] [consensus 3/3: valid=3]
raw comments (9)
app/controllers/admin/groups_controller.rb:93
**Removing a member leaves stale primary group** `remove_member` deletes the join row with `group.users.delete(user_id)`, but never clears the user's `primary_group_id`. The old `destroy_deletions` callback did that cleanup. Also run User.where(id: user_id, primary_group_id: group.id).update_all(primary_group_id: nil) when removing. ``` app/controllers/admin/groups_controller.rb:84 def remove_member app/controllers/admin/groups_controller.rb:85 group = Group.find(params.require(:group_id).to_i) app/controllers/admin/groups_controller.rb:86 user_id = params.require(:user_id).to_i app/controllers/admin/groups_controller.rb:88 return can_not_modify_automatic if group.automatic app/models/group.rb:287 def destroy_deletions app/models/group.rb:288 if @deletions app/models/group.rb:289 @deletions.each do |gu| app/models/group.rb:290 gu.destroy app/models/group.rb:291 User.where('id = ? AND primary_group_id = ?', gu.user_id, gu.group_id).update_all 'primary_group_id = NULL' app/models/group.rb:292 end ```
app/assets/javascripts/admin/controllers/admin-group.js.es6:10
**Extra empty page when members fill pages exactly** `totalPages` is `floor(user_count / limit) + 1`, so when `user_count` is an exact multiple of `limit` (e.g. 50 or 100) it reports one page too many. `showingLast` is then false on the real last page, and `next` moves to an empty page. Use Math.ceil(user_count / limit). ``` app/assets/javascripts/admin/controllers/admin-group.js.es6:9 }.property("limit", "offset", "user_count"), app/assets/javascripts/admin/controllers/admin-group.js.es6:11 totalPages: function() { app/assets/javascripts/admin/controllers/admin-group.js.es6:12 if (this.get("user_count") == 0) { return 0; } app/assets/javascripts/admin/controllers/admin-group.js.es6:6 currentPage: function() { app/assets/javascripts/admin/controllers/admin-group.js.es6:7 if (this.get("user_count") == 0) { return 0; } app/assets/javascripts/admin/controllers/admin-group.js.es6:8 return Math.floor(this.get("offset") / this.get("limit")) + 1; app/assets/javascripts/admin/controllers/admin-group.js.es6:13 return Math.floor(this.get("user_count") / this.get("limit")) + 1; app/assets/javascripts/admin/controllers/admin-group.js.es6:14 }.property("limit", "user_count"), app/assets/javascripts/admin/controllers/admin-group.js.es6:16 showingFirst: Em.computed.lte("currentPage", 1), ```
app/controllers/groups_controller.rb:23
**Negative limit or offset returns a 500** `members` now passes limit and offset from params into the query for every group, with no lower bound. A negative value fails in the database and the request returns a 500, including for non-automatic groups, which used to ignore these params. Clamp both to non-negative values, and cap the limit. ``` app/controllers/groups_controller.rb:22 limit = (params[:limit] || 50).to_i app/controllers/groups_controller.rb:23 offset = params[:offset].to_i app/controllers/groups_controller.rb:25 total = group.users.count app/controllers/groups_controller.rb:26 members = group.users.order(:username_lower).limit(limit).offset(offset) ```
app/assets/javascripts/discourse/routes/group-members.js.es6:11
**Public group page shows only first 50 members** The public group members page now calls `findMembers()` once, and the endpoint defaults to limit 50 for every group. `members.hbs` has no next/previous controls. Before, non-automatic groups returned all members and automatic groups returned 200. Add paging controls to the public members template, or keep the old unbounded behavior there. ``` app/assets/javascripts/discourse/routes/group-members.js.es6:8 setupController: function(controller, model) { app/assets/javascripts/discourse/routes/group-members.js.es6:9 this.controllerFor('group').set('showing', 'members'); app/assets/javascripts/discourse/routes/group-members.js.es6:10 controller.set("model", model); app/assets/javascripts/discourse/routes/group-members.js.es6:11 model.findMembers(); app/assets/javascripts/discourse/templates/group/members.hbs:1 {{#if model}} app/assets/javascripts/discourse/templates/group/members.hbs:2 <table class='group-members'> app/assets/javascripts/discourse/templates/group/members.hbs:3 <tr> app/assets/javascripts/discourse/templates/group/members.hbs:4 <th colspan="3" class="seen">{{i18n 'last_seen'}}</th> app/assets/javascripts/discourse/templates/group/members.hbs:5 </tr> app/assets/javascripts/discourse/templates/group/members.hbs:6 {{#each m in members}} ```
app/assets/javascripts/discourse/models/group.js:47
**Removing last page member leaves empty list** `removeMember` reloads with the unchanged `offset` and a stale `user_count`. If the removed member was the only one on the last page, the server returns no rows, and the page stays on a nonexistent page. After the response, if offset >= new total, move offset back one page and reload. ``` app/assets/javascripts/discourse/models/group.js:23 var self = this, offset = Math.min(this.get("user_count"), Math.max(this.get("offset"), 0)); app/assets/javascripts/discourse/models/group.js:25 return Discourse.ajax('/groups/' + this.get('name') + '/members.json', { app/assets/javascripts/discourse/models/group.js:26 data: { app/assets/javascripts/discourse/models/group.js:27 limit: this.get("limit"), ```
app/controllers/admin/groups_controller.rb:71
**Adding existing member raises duplicate error** `add_members` calls `group.add(user)` for every username without checking existing membership. The old `usernames=` code only added the difference. Adding someone already in the group inserts a duplicate group_users row, which fails on the unique index (500) or creates a duplicate. Skip users already in group.users, or use find_or_create on group_users. ``` app/controllers/admin/groups_controller.rb:69 return can_not_modify_automatic if group.automatic app/controllers/admin/groups_controller.rb:71 usernames.split(",").each do |username| app/controllers/admin/groups_controller.rb:72 if user = User.find_by_username(username) ```
app/assets/javascripts/admin/controllers/admin-group.js.es6:64
**Username input not cleared after adding members** `addMembers` leaves `usernames` set after a successful add. Clicking Add again resubmits the same names, which hits the duplicate-membership path in `add_members`. Clear `usernames` after the add request succeeds. ``` app/assets/javascripts/admin/controllers/admin-group.js.es6:61 addMembers: function() { app/assets/javascripts/admin/controllers/admin-group.js.es6:62 // TODO: should clear the input app/assets/javascripts/admin/controllers/admin-group.js.es6:63 if (Em.isEmpty(this.get("usernames"))) { return; } app/assets/javascripts/admin/controllers/admin-group.js.es6:64 this.get("model").addMembers(this.get("usernames")); ```
app/controllers/admin/groups_controller.rb:64
**add_members crashes if usernames is not a string** `add_members` calls `usernames.split(",")` on `params.require(:usernames)`. If the client sends `usernames[]=a`, it is an Array (or Hash) and `split` raises. Call usernames.to_s.split(',') or validate the param type. ``` app/controllers/admin/groups_controller.rb:60 def refresh_automatic_groups app/controllers/admin/groups_controller.rb:61 Group.refresh_automatic_groups! app/controllers/admin/groups_controller.rb:62 render json: success_json app/controllers/admin/groups_controller.rb:63 end app/controllers/admin/groups_controller.rb:65 def add_members app/controllers/admin/groups_controller.rb:66 group = Group.find(params.require(:group_id).to_i) ```
app/assets/javascripts/discourse/models/group.js:25
**Out-of-order paging responses overwrite state** `findMembers` has no guard for in-flight requests. `next`/`previous` change `offset` immediately but the response then overwrites `offset` and `members`. Clicking quickly sends several requests, and a slower earlier one can arrive last. Ignore responses from superseded requests, e.g. by tracking a request counter. ``` app/assets/javascripts/discourse/models/group.js:20 findMembers: function() { app/assets/javascripts/discourse/models/group.js:21 if (Em.isEmpty(this.get('name'))) { return ; } app/assets/javascripts/discourse/models/group.js:23 var self = this, offset = Math.min(this.get("user_count"), Math.max(this.get("offset"), 0)); app/assets/javascripts/discourse/models/group.js:25 return Discourse.ajax('/groups/' + this.get('name') + '/members.json', { app/assets/javascripts/discourse/models/group.js:31 self.setProperties({ app/assets/javascripts/discourse/models/group.js:32 user_count: result.meta.total, app/assets/javascripts/discourse/models/group.js:33 limit: result.meta.limit, app/assets/javascripts/discourse/models/group.js:34 offset: result.meta.offset, app/assets/javascripts/discourse/models/group.js:35 members: result.members.map(function(member) { return Discourse.User.create(member); }) app/assets/javascripts/discourse/models/group.js:36 }); ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✗ —
valid · matches d2 · impact low
valid · impact medium
Previously only automatic groups were limited; now every group's members request is capped at 50 and the public members page calls findMembers once with no pagination UI, so members beyond 50 are hidden. [grounded: diff] [consensus 3/3: valid=3]
invalid
The new create indeed omits alias_level, but the old create also only set name, usernames and visible, so the behavior is unchanged by this PR. [invalid: introduced=no] [consensus 3/3: invalid=3]
invalid
The `each member in members` keyword form should keep the parent controller as context in Ember 1.x. So `automatic` resolves to the group's flag, not the user's. The template itself reaches the user through `member.username`, which supports this. [invalid: contradiction] [consensus 3/3: invalid=3]
raw comments (5)
app/assets/javascripts/admin/controllers/admin-group.js.es6:14
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Pagination Adds Empty Page** When a group has exactly a multiple of 50 members, this calculation adds a page that does not exist. For example, a 100-member group reports three pages, leaves Next enabled on page two, and lets the administrator navigate to an empty third page. Use ceiling division so exact multiples produce the correct page count. ```suggestion totalPages: function() { if (this.get("user_count") == 0) { return 0; } return Math.ceil(this.get("user_count") / this.get("limit")); }.property("limit", "user_count"), ```
app/controllers/groups_controller.rb:26
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Public Members Are Truncated** The new 50-member limit applies to non-automatic groups as well as automatic groups. The public members page makes only one request and has no pagination or load-more control, so groups with more than 50 members now expose only the first 50. Previously, the page returned every member of non-automatic groups.
app/controllers/admin/groups_controller.rb:25
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Alias Level Is Discarded** When an administrator creates a group with a non-default alias level, the form sends `alias_level`, but this action never assigns it. The group is therefore saved with the default “nobody” level instead of the selected permission until the administrator saves it again. ```suggestion group = Group.new group.name = (params[:name] || '').strip group.visible = params[:visible] == "true" group.alias_level = params[:alias_level].to_i if params[:alias_level].present? ```
app/assets/javascripts/admin/templates/group_member.hbs:1
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Automatic Groups Show Removal** This condition reads `automatic` from each member item, but that property belongs to the parent group and is not defined on users. Automatic groups therefore display member-removal links; clicking one shows the confirmation and sends a request that the server rejects with a 422 response.
PR-level
<h3>Greptile Summary</h3> This PR introduces paginated group-member retrieval and dedicated administrative membership actions, while restructuring the group administration interface and request payloads. - Adds admin controls for browsing, adding, and removing group members. - Changes the public members endpoint to return member data with pagination metadata. - Separates group settings updates from membership mutations. - Updates templates, styling, localization, routes, and controller tests. <h3>Confidence Score: 3/5</h3> The PR is not safe to merge until public member truncation and lost alias-level persistence during group creation are corrected. The public page makes only one request after the server begins limiting every group to 50 members, making later members inaccessible, and the create endpoint ignores an alias level that the new-group UI submits. The admin UI also has lower-impact pagination and automatic-group removal-control defects. **Files Needing Attention:** app/controllers/groups_controller.rb, app/controllers/admin/groups_controller.rb, app/assets/javascripts/admin/controllers/admin-group.js.es6, app/assets/javascripts/admin/templates/group_member.hbs <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | app/controllers/groups_controller.rb | Adds a paginated response envelope, but unconditionally limits the public member list without adding public pagination. | | app/controllers/admin/groups_controller.rb | Adds dedicated membership actions and flat settings parameters, but create omits the submitted alias level. | | app/assets/javascripts/admin/controllers/admin-group.js.es6 | Adds member-management and pagination actions, with an off-by-one page-count calculation for exact multiples. | | app/assets/javascripts/discourse/models/group.js | Centralizes paginated member loading and separate membership mutation requests. | | app/assets/javascripts/admin/templates/group_member.hbs | Adds per-member removal controls, but evaluates the automatic-group guard against the item context. | | app/assets/javascripts/discourse/templates/group/members.hbs | Adapts the public template to model-backed members but provides no navigation for the newly paginated result. | </details> <details open><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart LR AdminUI[Admin group UI] --> GroupModel[Discourse.Group] PublicUI[Public members page] --> GroupModel GroupModel -->|GET name/members.json| Members[GroupsController#members] Members -->|members and pagination metadata| GroupModel GroupModel -->|PUT id/members.json| Add[Admin GroupsController#add_members] GroupModel -->|DELETE id/members.json| Remove[Admin GroupsController#remove_member] GroupModel -->|POST or PUT group settings| Settings[Admin GroupsController#create/update] ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update app/assets/javascripts/admin/cont..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/26f13a9018582878dbdd67ea80221388b8f66084) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284406)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✗ —
valid · impact low
With user_count=50 and limit=50 the pager shows 2 pages, and 'next' goes to an empty page. This is an off-by-one bug introduced in the new totalPages. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
Group#add is users.push(user), and group_users has a unique index on (group_id, user_id), so adding an existing member raises RecordNotUnique. The old usernames= path only added the difference, so it avoided this. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The old removal path used destroy_deletions, which set primary_group_id to NULL. The new remove_member only deletes the association, so a stale primary_group_id remains. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The limit used to apply only to automatic groups. It now defaults to 50 for every group, and the public members.hbs template has no paging controls. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact low
valid · impact medium
Same issue as finding 3: the public route fetches only the default 50 members, and the template has no pagination. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
Same issue as finding 1: pushing an existing member violates the unique index on group_users and causes a 500. [grounded: diff] [consensus 3/3: valid=3]
raw comments (7)
app/assets/javascripts/admin/controllers/admin-group.js.es6:12
[P2] Page count adds an extra empty page when the member count is an exact multiple of the limit `totalPages` is calculated as `Math.floor(user_count / limit) + 1`. When `user_count` is an exact multiple of `limit` (for example 50 members with the default limit of 50), this gives one page too many and the pager shows "1/2". Because `showingLast` is false, the "next" action moves the offset to `user_count` (50). `findMembers` then fetches and shows an empty member list on a page that shouldn't exist. Using `Math.ceil(user_count / limit)` would give the right count.
app/controllers/admin/groups_controller.rb:72
[P2] Adding a user who is already in the group causes a 500 error `add_members` calls `group.add(user)` (`users.push(user)`) for every username without checking whether the user is already a member. `group_users` has a UNIQUE index on `(group_id, user_id)`, so if an admin enters an existing member's username (alone or in a list), the insert raises `ActiveRecord::RecordNotUnique` and the request fails with a 500 instead of skipping that user. The old UI went through `usernames=`, which only added the difference, so this didn't happen before. The new admin form makes this easy to hit, since the input isn't cleared after adding (see the TODO).
app/controllers/admin/groups_controller.rb:88
[P2] Removing a member no longer clears their `primary_group_id` Before this change, members were removed from the admin UI through `Group#usernames=`. That path's `destroy_deletions` also ran `User...update_all 'primary_group_id = NULL'` for each removed user. The new `remove_member` endpoint only calls `group.users.delete(user_id)`. If the removed user had this group as their primary group, they keep a `primary_group_id` pointing at a group they're no longer in, so they still show that group's flair/primary-group styling.
app/assets/javascripts/discourse/templates/group/members.hbs:6
[P2] Public group members page now shows only the first 50 members, with no paging `GroupsController#members` now applies `limit` (default 50) to every group; previously the limit was applied only to automatic groups. The public `group/members` route calls `model.findMembers()` with the model's default `limit: 50`, but `members.hbs` has no next/previous controls. As a result, any non-automatic group with more than 50 members shows only the first 50 alphabetically on its public members page, where it used to show all of them, and there's no way to see the rest.
app/assets/javascripts/admin/controllers/admin-group.js.es6:13
[P2] totalPages is off by one when user_count is an exact multiple of limit `Math.floor(user_count / limit) + 1` adds an extra page whenever the count divides evenly. For example, a group with 50 members and limit 50 shows "1/2". Because `showingLast` compares currentPage to totalPages, the "next" button stays enabled. Clicking it sets offset to 50, so `findMembers` fetches an empty page and the admin sees no members. This affects any group whose size is a multiple of 50, including one that reaches that size after a member is added or removed. Using `Math.ceil(user_count / limit)` fixes it.
app/assets/javascripts/discourse/routes/group-members.js.es6:8
[P2] Public group members page now shows only the first 50 members, with no way to page `GroupsController#members` now defaults to `limit=50` for every group, and the public `group-members` route calls `model.findMembers()` with the model's default limit/offset. The public `group/members.hbs` template has no next/previous controls; pagination was only added to the admin template. Before this change, non-automatic groups returned their full member list, and automatic groups returned up to 200. Any group with more than 50 members now has a truncated public members page with no way to see the rest.
app/controllers/admin/groups_controller.rb:69
[P2] Adding a user who is already in the group raises a 500 error `add_members` calls `group.add(user)` (`users.push`) for every username without checking whether the user is already a member. `group_users` has a unique index on `(group_id, user_id)`, so pushing an existing member raises `ActiveRecord::RecordNotUnique`. The request then fails with a 500, and any later usernames in the same request are not processed. The old admin UI path assigned `usernames=`, which diffed against the current members and avoided this. With the new "Add members" box, an admin can easily enter someone who is already in the group, because the user-selector does not exclude existing members.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✓ off by one
d3 medium ✓ exact
valid · impact low
With 50 members and limit 50, totalPages = 2 and showingLast is false on page 1. Clicking next sets offset to 50, which returns an empty page. Ceiling division is needed. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
Before, the limit applied only to automatic groups. Now every group defaults to 50, and the public members route calls findMembers once with no pagination controls, so members beyond 50 cannot be reached. The citation check failed only because the reviewer cited the file without its .es6 suffix; group-members.js.es6 appears in the diff. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · matches d2 · impact low
valid · impact medium
The old removal paths destroyed GroupUser records (Group#remove and destroy_deletions), and destroy_deletions also cleared primary_group_id. The new delete on the has_many :through association deletes the join rows directly, without destroy callbacks and without clearing primary_group_id. The primary_group_id half is certain; whether user_count goes stale depends on how Rails handles the counter cache on this path, so that half is less certain. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
This is the same issue as finding 1. The public members page is now limited to 50 members with no pagination controls. [grounded: diff] [consensus 3/3: valid=3]
raw comments (6)
app/assets/javascripts/admin/controllers/admin-group.js.es6:11
[P2] totalPages overcounts when user_count is an exact multiple of limit `Math.floor(user_count / limit) + 1` yields one extra page whenever the count divides evenly. For example, 50 members with limit 50 shows "1/2", and `showingLast` is false on page 1. Clicking next sets offset to `min(50, 50)` = 50, so the member list is empty. It should use a ceiling division.
app/controllers/groups_controller.rb:22
[P2] Public group members page is silently truncated to 50 with no pagination `members` now always applies `limit` (default 50) and `offset` for every group. Before, only automatic groups were limited, to 200. The public `group/members` template and route (`group-members.js.es6`) call `findMembers()` once with the default limit and have no next/previous UI. Any non-automatic group with more than 50 members now shows only the first 50 on its public members page, and the rest cannot be reached.
app/controllers/admin/groups_controller.rb:90
[P2] remove_member uses `group.users.delete`, which bypasses the GroupUser counter cache `group.users.delete(user_id)` on a has_many :through deletes the join rows without running destroy callbacks. `GroupUser` has `belongs_to :group, counter_cache: "user_count"`, so `groups.user_count` is not decremented. The old PATCH path used `group.remove`, which destroys the GroupUser records and so updated the counter. The stale `user_count` shows up in the group list (`userCountDisplay`) and elsewhere. It also does not clear `primary_group_id`, which the old `usernames=`/`destroy_deletions` path did. Using `group.remove(user)` would avoid both.
app/assets/javascripts/admin/controllers/admin-group.js.es6:12
[P2] Page count is off by one when the member count is a multiple of the page size `totalPages` uses `Math.floor(user_count / limit) + 1`, so a group with exactly 50 (or 100, …) members reports 2 pages when it has 1. `showingLast` is then false on the real last page. The "next" button stays enabled, and clicking it sets `offset = min(offset + limit, user_count)`, which loads an empty page. Use a ceiling division instead.
app/controllers/admin/groups_controller.rb:90
[P2] Removing a member skips GroupUser callbacks, so `user_count` and `primary_group_id` go stale `group.users.delete(user_id)` on the has_many :through association removes the join rows with `delete_all` (Rails 4.1.8). It does not run `GroupUser` destroy callbacks. `GroupUser` has `belongs_to :group, counter_cache: "user_count"`, so `groups.user_count` is not decremented. The admin UI reads that value for the member count and for pagination, and the group list shows it too. The old PUT/PATCH path went through `destroy_deletions` or `group.remove`, which destroyed the `GroupUser` records, and `destroy_deletions` also cleared the user's `primary_group_id`. After this change, a removed user can keep `primary_group_id` pointing at a group they are no longer in. Destroy the `GroupUser` records instead, for example via `group.remove(user)`, and clear `primary_group_id`.
app/controllers/groups_controller.rb:22
[P2] Public group members page now shows only the first 50 members, with no pagination `GroupsController#members` now applies `limit` (default 50) and `offset` to every group. Before, the limit applied only to automatic groups, and its default was 200. `group-members.js.es6` calls `findMembers()` with the model's default `limit: 50, offset: 0`. `group/members.hbs` has no next/previous controls. The public page therefore silently truncates any group with more than 50 members, and members 51 and beyond cannot be seen. Pagination was added only to the admin UI.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d2 low ✗ —
d3 medium ✗ —
raw comments (2)
PR-level
<h3>Qodo is busy working</h3> Check back in a few minutes. Qodo's code review agents are on it. <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <img src="https://www.qodo.ai/wp-content/uploads/2026/01/anteater-looking-at-ants-01-transparent-bg-croped-ezgif.com-optimize-1.gif" width="30%">
PR-level
<h3>PR Summary by Qodo</h3> Add paginated group membership administration <code>✨ Enhancement</code> <code>🐞 Bug fix</code> <code>🧪 Tests</code> <code>🕐 40+ Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Adds paginated member loading with counts across admin and public group views. >• Separates group settings from dedicated member addition and removal APIs. >• Refreshes admin forms, membership controls, styling, translations, and controller coverage. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid sequenceDiagram actor Admin actor Visitor participant AdminUI as Admin UI participant PublicUI as Group Page participant Model as Group Model participant MembersAPI as Members API participant AdminAPI as Admin API participant DB as Group Store Admin->>AdminUI: Open group Visitor->>PublicUI: View members AdminUI->>Model: Load page PublicUI->>Model: Load members Model->>MembersAPI: GET limit and offset MembersAPI->>DB: Query members and count DB-->>MembersAPI: Members and total MembersAPI-->>Model: Page with metadata Model-->>AdminUI: Render controls Model-->>PublicUI: Render members Admin->>AdminUI: Add or remove member AdminUI->>Model: Mutate membership Model->>AdminAPI: PUT or DELETE member AdminAPI->>DB: Update group membership AdminAPI-->>Model: Success Model->>MembersAPI: Reload current page ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Cursor-based member pagination</b></summary> <dl> <dd> - ➕ Avoids skipped or duplicated members when membership changes between requests - ➕ Scales better for very large groups - ➖ Does not naturally support numbered pages - ➖ Requires a more extensive API and UI state redesign </dd> </dl> </details> <details> <summary><b>2. Retain membership updates in the group update endpoint</b></summary> <dl> <dd> - ➕ Uses fewer routes and client methods - ➕ Allows settings and membership to be submitted together - ➖ Couples independent operations and payload formats - ➖ Makes incremental membership changes less explicit - ➖ Risks replacing the complete membership set during settings edits </dd> </dl> </details> >**Recommendation:** Keep the PR&#x27;s dedicated membership endpoints and offset pagination. This cleanly separates group settings from incremental membership operations while fitting the existing page-number interface; cursor pagination would only be preferable if concurrent changes or very large groups become dominant concerns. </dd> </dl> </details> <details> <summary> Files changed (16) <code> +389 / -283 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (8) <code> +264 / -143 </code></summary> <dl> <dd> <details> <summary>admin-group.js.es6<code>Add paginated membership administration actions</code> <code>+58/-23</code></summary> <br/> >Add paginated membership administration actions > ><pre> >• Adds page calculations, navigation actions, confirmation-based removal, and member addition. Group settings now save independently from membership changes through the model&#x27;s dedicated methods. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-613da82e57ee13e5941aabc2b409c57f9f7cc4b26ed2f036334fc678e8d75938'>app/assets/javascripts/admin/controllers/admin-group.js.es6</a> </details> <details> <summary>group.hbs<code>Redesign the admin group form and member controls</code> <code>+49/-25</code></summary> <br/> >Redesign the admin group form and member controls > ><pre> >• Reworks the form layout and adds member totals, page navigation, member cards, addition controls, and updated action buttons. Automatic groups retain read-only membership behavior. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-003241d74c2b4d8fc0df5dd5e133c0b274145a03cd120003a8f8ebe8772e8164'>app/assets/javascripts/admin/templates/group.hbs</a> </details> <details> <summary>group_member.hbs<code>Render individual admin group members</code> <code>+1/-0</code></summary> <br/> >Render individual admin group members > ><pre> >• Adds a compact member row with avatar, username, and conditional removal action. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-efe16a7610371be3a0f62d2a376733b31930f110cf70daf7f369f12458428ed5'>app/assets/javascripts/admin/templates/group_member.hbs</a> </details> <details> <summary>group-member.js.es6<code>Introduce the group member item view</code> <code>+4/-0</code></summary> <br/> >Introduce the group member item view > ><pre> >• Defines the item class and template binding used by the admin membership list. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-0d864af95c653e74c59d2832df9aa22377894374adab1a9721be8830a8d7f0d5'>app/assets/javascripts/admin/views/group-member.js.es6</a> </details> <details> <summary>group.js<code>Centralize group pagination and membership API operations</code> <code>+54/-27</code></summary> <br/> >Centralize group pagination and membership API operations > ><pre> >• Adds membership pagination state and consumes the new metadata response from the public members endpoint. Introduces dedicated add/remove operations and simplifies group create and save payloads to exclude usernames. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-52c6bbdd5b1decd887a14c5798f1938b370795ebf19fe9bc199df965dd0a3cb8'>app/assets/javascripts/discourse/models/group.js</a> </details> <details> <summary>members.hbs<code>Render members from group model state</code> <code>+1/-1</code></summary> <br/> >Render members from group model state > ><pre> >• Changes the public member table to iterate over the model&#x27;s members collection rather than treating the route model as a member array. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-03ede83e4f3d0138856b906b5c998896a09604cc221477d2df70bf4e9b3d04c9'>app/assets/javascripts/discourse/templates/group/members.hbs</a> </details> <details> <summary>admin_base.scss<code>Style group forms and paginated member controls</code> <code>+40/-15</code></summary> <br/> >Style group forms and paginated member controls > ><pre> >• Shares horizontal form styling between groups and badges. Adds group-specific member card sizing, pagination states, and add-button spacing. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-aa59b16dc08f34adecba92453798e09cc7e57a3ba5bbefb3127e933d83778bc8'>app/assets/stylesheets/common/admin/admin_base.scss</a> </details> <details> <summary>groups_controller.rb<code>Separate group settings and membership operations</code> <code>+57/-52</code></summary> <br/> >Separate group settings and membership operations > ><pre> >• Simplifies create and update parameters while preserving automatic-group name restrictions. Adds dedicated member addition and removal actions with automatic-group protection and consistent error responses. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-6a7ec5ae57f16b2ee80d878808ba101da75a4c0799088e9363128412ee0a8fcd'>app/controllers/admin/groups_controller.rb</a> </details> </dd> </dl> </details> <details> <summary>Bug fix (1) <code> +20 / -17 </code></summary> <dl> <dd> <details> <summary>groups_controller.rb<code>Return paginated group members with metadata</code> <code>+20/-17</code></summary> <br/> >Return paginated group members with metadata > ><pre> >• Applies limit and offset pagination to every group and returns members alongside total, limit, and offset metadata. This replaces the prior truncated flat member response. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-af3ad490ca40c9ba7d5641ead932a1b6af38ec2b4af21c0f8468b11ed97f0ba5'>app/controllers/groups_controller.rb</a> </details> </dd> </dl> </details> <details> <summary>Refactor (4) <code> +15 / -28 </code></summary> <dl> <dd> <details> <summary>admin_group_route.js<code>Load members directly into the group model</code> <code>+3/-9</code></summary> <br/> >Load members directly into the group model > ><pre> >• Removes route-owned member state and deferred after-model handling. The controller receives the group model while membership loading updates that model directly. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-3f4d6f5fb38547e0c07d177b9250d181bdd8053a874071e1199286396454a6b9'>app/assets/javascripts/admin/routes/admin_group_route.js</a> </details> <details> <summary>group-members.js.es6<code>Use the group model for public member loading</code> <code>+3/-10</code></summary> <br/> >Use the group model for public member loading > ><pre> >• Removes temporary route state and triggers member loading directly on the shared group model during controller setup. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-6de14295baacd616b148ee06342aa67bfa66d640e8794e72495864b998ab57ca'>app/assets/javascripts/discourse/routes/group-members.js.es6</a> </details> <details> <summary>admin-group-selector.hbs<code>Normalize the admin group selector template</code> <code>+0/-2</code></summary> <br/> >Normalize the admin group selector template > ><pre> >• Removes unnecessary blank lines around the selector input. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-4ba3a144ebced7168c5e05b1c873a4397495a476f0078e6114863beabdc7297c'>app/assets/javascripts/discourse/templates/components/admin-group-selector.hbs</a> </details> <details> <summary>user-selector-autocomplete.raw.hbs<code>Clarify autocomplete result markup</code> <code>+9/-7</code></summary> <br/> >Clarify autocomplete result markup > ><pre> >• Reformats user and group result links into consistently nested markup without changing selection behavior. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-8426197baf6882fef7e18a6b79444f46a064b34f30adf4b13ce38e429cd42067'>app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs</a> </details> </dd> </dl> </details> <details> <summary>Tests (1) <code> +83 / -93 </code></summary> <dl> <dd> <details> <summary>groups_controller_spec.rb<code>Cover revised group administration endpoints</code> <code>+83/-93</code></summary> <br/> >Cover revised group administration endpoints > ><pre> >• Reorganizes controller examples and validates name normalization, automatic-group protections, settings updates, member addition, and member removal. Replaces tests for the former PATCH-based membership workflow. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-67cc913763e1d78ac097b2a82cf5296c070d548c1b706396dd9035d7f7382e14'>spec/controllers/admin/groups_controller_spec.rb</a> </details> </dd> </dl> </details> <details> <summary>Documentation (1) <code> +5 / -1 </code></summary> <dl> <dd> <details> <summary>client.en.yml<code>Add admin membership management translations</code> <code>+5/-1</code></summary> <br/> >Add admin membership management translations > ><pre> >• Adds labels and confirmation text for group names, member addition, and member removal while refining the username selector placeholder. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-d311cd526428b83a1ebb9ed9b457fb210800cc5f0e8188af7de7b5ce86aa5315'>config/locales/client.en.yml</a> </details> </dd> </dl> </details> <details> <summary>Other (1) <code> +2 / -1 </code></summary> <dl> <dd> <details> <summary>routes.rb<code>Expose dedicated group membership routes</code> <code>+2/-1</code></summary> <br/> >Expose dedicated group membership routes > ><pre> >• Adds nested PUT and DELETE admin routes for adding and removing group members. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/35/files#diff-959bc9abc46a55332bb64d5155a79323afa75a50ec1a2137ddd22d926f62c6c5'>config/routes.rb</a> </details> </dd> </dl> </details> </dd> </dl> </details>