From 88cd677826db85c418721f5168e6f9d75ec768dc 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 c9514c998..218f1f3c9 100644 --- a/gitlab/v4/objects/labels.py +++ b/gitlab/v4/objects/labels.py @@ -20,7 +20,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. @@ -81,7 +82,8 @@ def update( # type: ignore[override] 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.