You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example is an MVP example; actually making changes to the rule object before calling .save() doesn't change the behaviour
Expected Behavior
The function should succeed silently, returning None
Actual Behavior
gitlab.exceptions.GitlabUpdateError: 404: 404 Not found is thrown. Trying it with debug mode on, it appears as though the root cause of the issue is that when the CLI invokes /projects/:id/merge_requests/:merge_request_iid/approval_rules/:approval_rule_id in the API, :id (i.e. project ID) is passed where the URL expects :approval_rule_id, as can be seen from this debug output (anonymized to remove sensitive information)
We might be able to just get rid of that custom save method, things might be more consistent these days. I don't use Premium features personally, so this needs some digging on why we even have that in the code.
Indeed the used identifier is incorrect. It would perform a call to /api/v4/projects/1/merge_requests/1/approval_rules/3 instead of /api/v4/projects/1/merge_requests/1/approval_rules/1 when saving.
The unit test here does not catch that, since the project ID, merge request ID, and approval rule ID are all 1, so a mix up is not detected.
Activity
nejch commentedon Apr 17, 2023
Looks like we have some old code here:
https://github.com/python-gitlab/python-gitlab/blame/eb54adf2fe7d3c68dcb6021065e51ba33b7bbc04/gitlab/v4/objects/merge_request_approvals.py#L155
We might be able to just get rid of that custom save method, things might be more consistent these days. I don't use Premium features personally, so this needs some digging on why we even have that in the code.
fix(api): fix saving merge request approval rules
fix(api): fix saving merge request approval rules
fix(api): fix saving merge request approval rules
Sjord commentedon Jan 22, 2024
Indeed the used identifier is incorrect. It would perform a call to /api/v4/projects/1/merge_requests/1/approval_rules/3 instead of /api/v4/projects/1/merge_requests/1/approval_rules/1 when saving.
The unit test here does not catch that, since the project ID, merge request ID, and approval rule ID are all 1, so a mix up is not detected.
Docs for this feature:
fix(api): fix saving merge request approval rules
fix(api): fix saving merge request approval rules
jarodwilson commentedon May 13, 2024
We're actively encountering this bug ourselves, was there a plan to get #2773 merged?
fix(api): fix saving merge request approval rules
fix(api): fix saving merge request approval rules
fix(api): fix saving merge request approval rules
JohnVillalovos commentedon May 14, 2024
It is now merged and a new release of python-gitlab was made.