-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(api): use ID instead of name for GroupLabel & ProjectLabel _id_attr #2811
base: main
Are you sure you want to change the base?
Conversation
This change makes sense to me but maybe the original behaviour is preferred for some reason. I stumbled upon this when fetching all the labels for a number of groups and projects. I put them in a set() and ended up with a lot less items than I expected. |
This change makes a lot of sense, thanks @ptalbert. For context, we didn't use to have I think this might be a breaking change though, as people might be comparing labels for uniqueness, so I also wonder if we should be using |
https://docs.gitlab.com/ee/api/labels.html only shows an I see the functional tests for groups and projects broke. I don't have docker so I cannot immediately run those tests locally. I will try to get something working. |
Quite a few objects use
And there is a similar issue with ProjectMergeRequest objects. The Looks like epics and issues also suffer:
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. |
@ptalbert thanks. In some cases The |
@ptalbert I think for others it mostly makes sense to keep But for this one it makes sense probably, we just need to make sure the tests pass and add a breaking change trailer in your commit message so we ensure a major release for this. Let me know if you need any help. |
_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>
Changes
_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.
Documentation and testing
Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated: