Updating a protected branch overwrites code_owner_approval_required
Summary
Calling PATCH /projects/:id/protected_branches/:name resets the code_owner_approval_required setting of the edited protected branch to false.
Steps to reproduce
- Enable the
Code Owner Approvalsetting for your branch:
- Call
PATCH /projects/:id/protected_branches/:namelike:
curl --request PATCH "https://gitlab.self.managed/api/v4/projects/55843/protected_branches/main"
-H 'PRIVATE-TOKEN: <GITLAB_TOKEN>'
-H 'Content-Type: application/json'
--data '{"allowed_to_merge":[{"access_level":0}]}'
- Check the
Code Owner Approvalsetting:
Example Project
Not possible as it was reproduced on internally hosted Gitlab and it needs premium to call those endpoints. Which I don't have on gitlab.com.
What is the current bug behavior?
Even though I only wish to set the allowed_to_merge access_level to 0 it also sets the code_owner_approval_required to false.
What is the expected correct behavior?
Because I am not mentioning code_owner_approval_required in the body of the PATCH I am expecting it not to change values.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Reproduced on version 16.1.3-ee.
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)

