Skip to content

Commit d138c45

Browse files
committed
Fix _get_members_set to get role name
1 parent b71471a commit d138c45

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libs/labelbox/src/labelbox/schema/user_group.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,12 @@ def _get_members_set(
679679
member_nodes = members_data.get("nodes", [])
680680
user_group_roles = members_data.get("userGroupRoles", [])
681681

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+
682688
# Create a mapping from userId to roleId
683689
user_role_mapping = {
684690
role_data["userId"]: role_data["roleId"]
@@ -694,15 +700,9 @@ def _get_members_set(
694700

695701
# Get the role for this user from the mapping
696702
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]
706706
members.add(UserGroupMember(user=user, role=role))
707707

708708
return members

0 commit comments

Comments
 (0)