fix(api): use ID instead of name for GroupLabel & ProjectLabel _id_attr by ptalbert · Pull Request #2811 · python-gitlab/python-gitlab
Quite a few objects use name as their _id_attr :/
python-gitlab (main)$ grep -nrB1 '_id_attr = "name"' gitlab/
gitlab/v4/objects/branches.py-21-class ProjectBranch(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/branches.py:22: _id_attr = "name"
--
gitlab/v4/objects/branches.py-37-class ProjectProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/branches.py:38: _id_attr = "name"
--
gitlab/v4/objects/container_registry.py-35-class ProjectRegistryTag(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/container_registry.py:36: _id_attr = "name"
--
gitlab/v4/objects/environments.py-62-class ProjectProtectedEnvironment(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/environments.py:63: _id_attr = "name"
--
gitlab/v4/objects/features.py-19-class Feature(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/features.py:20: _id_attr = "name"
--
gitlab/v4/objects/groups.py-430-class GroupSAMLGroupLink(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/groups.py:431: _id_attr = "name"
--
gitlab/v4/objects/tags.py-15-class ProjectTag(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/tags.py:16: _id_attr = "name"
--
gitlab/v4/objects/tags.py-32-class ProjectProtectedTag(ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/tags.py:33: _id_attr = "name"
--
gitlab/v4/objects/templates.py-18-class Dockerfile(RESTObject):
gitlab/v4/objects/templates.py:19: _id_attr = "name"
--
gitlab/v4/objects/templates.py-30-class Gitignore(RESTObject):
gitlab/v4/objects/templates.py:31: _id_attr = "name"
--
gitlab/v4/objects/templates.py-42-class Gitlabciyml(RESTObject):
gitlab/v4/objects/templates.py:43: _id_attr = "name"
--
gitlab/v4/objects/labels.py-25-class GroupLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
gitlab/v4/objects/labels.py:26: _id_attr = "name"
--
gitlab/v4/objects/labels.py-89-):
gitlab/v4/objects/labels.py:90: _id_attr = "name"
And there is a similar issue with ProjectMergeRequest objects. The _id_attr is iid. This means if you compare two MRs from completely different projects they will be seen as equal if they happen to have the same IID value.
Looks like epics and issues also suffer:
python-gitlab (main)$ grep -nr '_id_attr = "iid"' gitlab/
gitlab/v4/objects/epics.py:29: _id_attr = "iid"
gitlab/v4/objects/issues.py:117: _id_attr = "iid"
gitlab/v4/objects/merge_requests.py:155: _id_attr = "iid"
I imagine most of these objects never get compared but you never know, and certainly a Merge Request might. It seems prudent to fix these.