Skip to content

Commit 751cc74

Browse files
committed
remove constraints on roles
1 parent d2ebd76 commit 751cc74

File tree

1 file changed

+7
-44
lines changed

1 file changed

+7
-44
lines changed

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

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from collections import defaultdict
1010
from dataclasses import dataclass
1111
from enum import Enum
12-
from typing import Any, ClassVar, Dict, Iterator, List, Optional, Set
12+
from typing import Any, Dict, Iterator, List, Optional, Set
1313

1414
from lbox.exceptions import (
1515
InvalidQueryError,
@@ -109,14 +109,6 @@ class UserGroup(BaseModel):
109109
UserGroups. Users with any organization role will be rejected.
110110
"""
111111

112-
# UserGroup roles that cannot be assigned (from Labelbox business rules)
113-
UNASSIGNABLE_USERGROUP_ROLES: ClassVar[Set[str]] = {
114-
"ADMIN",
115-
"DATA_ADMIN",
116-
"READ-ONLY_ADMIN",
117-
"TENANT_ADMIN",
118-
}
119-
120112
id: str
121113
name: str
122114
color: UserGroupColor
@@ -579,51 +571,22 @@ def _build_user_roles(
579571
580572
Returns:
581573
List of user role dictionaries for the GraphQL mutation.
582-
583-
Raises:
584-
ValueError: If any UserGroup roles are invalid/unassignable.
585574
"""
586575
user_roles: List[Dict[str, str]] = []
587-
invalid_roles = []
588576

589577
# Add legacy users with default role
590578
for user in self.users:
591579
if user in eligible_users and self.default_role is not None:
592-
if (
593-
self.default_role.name.upper()
594-
in self.UNASSIGNABLE_USERGROUP_ROLES
595-
):
596-
invalid_roles.append(
597-
f"Default role '{self.default_role.name}' cannot be assigned in UserGroups"
598-
)
599-
else:
600-
user_roles.append(
601-
{"userId": user.uid, "roleId": self.default_role.uid}
602-
)
580+
user_roles.append(
581+
{"userId": user.uid, "roleId": self.default_role.uid}
582+
)
603583

604584
# Add members with their explicit roles
605585
for member in self.members:
606586
if member.user in eligible_users:
607-
if (
608-
member.role.name.upper()
609-
in self.UNASSIGNABLE_USERGROUP_ROLES
610-
):
611-
invalid_roles.append(
612-
f"Role '{member.role.name}' for user {member.user.uid} cannot be assigned in UserGroups"
613-
)
614-
else:
615-
user_roles.append(
616-
{"userId": member.user.uid, "roleId": member.role.uid}
617-
)
618-
619-
# Raise error if any invalid roles found
620-
if invalid_roles:
621-
raise ValueError(
622-
f"Cannot create UserGroup with invalid roles.\n"
623-
f"Unassignable roles: {', '.join(self.UNASSIGNABLE_USERGROUP_ROLES)}\n"
624-
f"Issues found:\n"
625-
+ "\n".join(f" • {detail}" for detail in invalid_roles)
626-
)
587+
user_roles.append(
588+
{"userId": member.user.uid, "roleId": member.role.uid}
589+
)
627590

628591
return user_roles
629592

0 commit comments

Comments
 (0)