Skip to content

Commit 88cd677

Browse files
committed
fix(api): use ID instead of name for GroupLabel & ProjectLabel _id_attr
_id_attr is used when comparing RESTObject objects. Labels will be seen as equal when they have the same name even if they are from different groups or projects. Instead, use the label's ID as the _id_attr so that comparisions will only be equal if they truly represent the same gitlab label object. Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
1 parent 22243f6 commit 88cd677

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gitlab/v4/objects/labels.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121

2222
class GroupLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
23-
_id_attr = "name"
23+
_id_attr = "id"
24+
_repr_attr = "name"
2425
manager: GroupLabelManager
2526

2627
# Update without ID, but we need an ID to get from list.
@@ -81,7 +82,8 @@ def update( # type: ignore[override]
8182
class ProjectLabel(
8283
PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject
8384
):
84-
_id_attr = "name"
85+
_id_attr = "id"
86+
_repr_attr = "name"
8587
manager: ProjectLabelManager
8688

8789
# Update without ID, but we need an ID to get from list.

0 commit comments

Comments
 (0)