Actions
Defect #38443
closedCannot add a user to a group if the group is a member without roles in a certain project
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
An exception will be raised if you attempt to add a user to a group if the group is a member without any roles in a certain project. The attempt will fail with the following error.
Completed 422 Unprocessable Entity in 36ms (ActiveRecord: 14.5ms | Allocations: 14551) ActiveRecord::RecordInvalid (Validation failed: Role cannot be empty): app/models/group.rb:90:in `block in user_added' app/models/group.rb:81:in `user_added' app/controllers/groups_controller.rb:118:in `add_users' lib/redmine/sudo_mode.rb:61:in `sudo_mode
You can reproduce the error with the following steps:
1. Add a group as a project member with any role
2. Edit the member and clear checkboxes for all roles and save
3. Go to Administration > Groups
4. Add a user to the group. You cannot add a group. The above error will be logged
Files
Related issues
Updated by Go MAEDA over 1 year ago
- Related to Defect #37166: Roles of a project member should not be made empty added
Updated by Go MAEDA over 1 year ago
diff --git a/app/models/group.rb b/app/models/group.rb
index 92a378e6e..1cfc6b56c 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -80,6 +80,8 @@ class Group < Principal
def user_added(user)
members.preload(:member_roles).each do |member|
next if member.project_id.nil?
+ # skip if the group is a member without roles in the project
+ next if member.member_roles.empty?
user_member =
Member.find_or_initialize_by(:project_id => member.project_id, :user_id => user.id)
Updated by Go MAEDA over 1 year ago
- Target version set to 5.0.6
Setting the target version to 5.0.6.
Updated by Go MAEDA over 1 year ago
- Status changed from New to Resolved
Committed the patch in r22180.
Updated by Go MAEDA over 1 year ago
- Status changed from Resolved to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Actions