@@ -679,6 +679,12 @@ def _get_members_set(
679
679
member_nodes = members_data .get ("nodes" , [])
680
680
user_group_roles = members_data .get ("userGroupRoles" , [])
681
681
682
+ # Get all roles to map IDs to names
683
+ from labelbox .schema .role import get_roles
684
+
685
+ all_roles = get_roles (self .client )
686
+ role_id_to_role = {role .uid : role for role in all_roles .values ()}
687
+
682
688
# Create a mapping from userId to roleId
683
689
user_role_mapping = {
684
690
role_data ["userId" ]: role_data ["roleId" ]
@@ -694,15 +700,9 @@ def _get_members_set(
694
700
695
701
# Get the role for this user from the mapping
696
702
role_id = user_role_mapping .get (node ["id" ])
697
- if role_id :
698
- # We need to fetch the role details since we only have the roleId
699
- # For now, create a minimal Role object with just the ID
700
- role_values : defaultdict [str , Any ] = defaultdict (lambda : None )
701
- role_values ["id" ] = role_id
702
- # We don't have the role name from this response, so we'll leave it as None
703
- # The Role object will fetch the name when needed
704
- role = Role (self .client , role_values )
705
-
703
+ if role_id and role_id in role_id_to_role :
704
+ # Use the actual Role object with proper name resolution
705
+ role = role_id_to_role [role_id ]
706
706
members .add (UserGroupMember (user = user , role = role ))
707
707
708
708
return members
0 commit comments