Description
Description of the problem, including code/CLI snippet
gl.project.get(proj_id).merge_requests.get(mr_iid).approval_rules.get(rule_id).save()
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)
>>> rule.save()
DEBUG:urllib3.connectionpool:Resetting dropped connection: mygitlab.example.com
send: b'PUT /api/v4/projects/93/merge_requests/1/approval_rules/93 HTTP/1.1\r\nHost: mygitlab.example.com\r\nUser-Agent: python-gitlab/3.14.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: TOKEN\r\nContent-type: application/json\r\nContent-Length: 768\r\n\r\n'
send: b'{"id": "93", "merge_request_iid": "1", "approval_rule_id": 89, "name": "testrule", "approvals_required": 1, "users": ["{\\"id\\": 168, \\"username\\": \\"myusername\\", \\"name\\": \\"My Name\\", \\"state\\": \\"active\\", \\"avatar_url\\": \\"https://secure.gravatar.com/avatar/8306d9f17d1c91970c2447b61c7a9f29?s=80&d=identicon\\", \\"web_url\\": \\"https://mygitlab.example.com/myusername\\", \\"created_at\\": \\"2023-03-29T14:30:13.371Z\\", \\"bio\\": \\"\\", \\"location\\": null, \\"public_email\\": null, \\"skype\\": \\"\\", \\"linkedin\\": \\"\\", \\"twitter\\": \\"\\", \\"website_url\\": \\"\\", \\"organization\\": null, \\"job_title\\": \\"\\", \\"pronouns\\": null, \\"bot\\": false, \\"work_information\\": null, \\"followers\\": 0, \\"following\\": 0, \\"is_followed\\": false, \\"local_time\\": null}"]}'
reply: 'HTTP/1.1 404 Not Found\r\n'
Specifications
- python-gitlab version: 3.14.0
- API version you are using (v3/v4): v4
- Gitlab server version (or gitlab.com): 15.7.2-ee