From 2cbd674e91ed1901d0b8b68346ae0b27d375d32f Mon Sep 17 00:00:00 2001 From: Patrick Talbert Date: Mon, 26 Feb 2024 12:45:57 +0100 Subject: [PATCH] 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 --- gitlab/v4/objects/labels.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gitlab/v4/objects/labels.py b/gitlab/v4/objects/labels.py index 32d4f6ba0..d1d728098 100644 --- a/gitlab/v4/objects/labels.py +++ b/gitlab/v4/objects/labels.py @@ -23,7 +23,8 @@ class GroupLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject): - _id_attr = "name" + _id_attr = "id" + _repr_attr = "name" manager: "GroupLabelManager" # Update without ID, but we need an ID to get from list. @@ -87,7 +88,8 @@ def update( # type: ignore class ProjectLabel( PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject ): - _id_attr = "name" + _id_attr = "id" + _repr_attr = "name" manager: "ProjectLabelManager" # Update without ID, but we need an ID to get from list.