Skip to content

git push/force push reloads incorrect CODEOWNERS in Merge Request.

Summary

When using bot users as in CODEOWNERS file, they get dropped from the approver list after user pushes additional changes to the MR.

Steps to reproduce

We have a CODEOWNERS file like below:

# All changes needs at least 1 approval from this section. Note the BOT USER.
[OPA OR ADMIN]
* @okta-groups/group1 @project_xxxxx_bot1

# All changes needs at least 1 approval from this section with the exception of changes in /folder/
[REPOSITORY OWNER]
* @okta-groups/group1
/folder/

# All changes to the relevant sub-folders needs approval from respective okta-groups.
[SERVICE OWNER]
/folder/sub-folder1/ @okta-groups/group1
/folder/sub-folder2/ @okta-groups/group1
/folder/sub-folder3/ @okta-groups/group1
/folder/sub-folder4/ @okta-groups/group2
/folder/sub-folder5/ @okta-groups/group2
/folder/sub-folder6/ @okta-groups/group2

Issue occurs in the following scenario.

  1. User makes changes to an existing file in /anotherfolder/myfile.txt.
  2. User creates a feature branch and submit a MR to merge into main.
  3. In the MR, CODEOWNERS get parsed and the following approvals are noted to be required.
    • [OPA OR ADMIN], allowed approvers are @okta-groups/group1 and @project_xxxxx_bot1
    • [RESPOSITORY OWNER], allowed approvers are @okta-groups/group1
  4. The user than makes an additional change to the file /anotherfolder/myfile.txt. Make a new commit and push the feature branch again.
  5. In the MR, CODEOWNERS gets updated to:
    • [OPA OR ADMIN], allowed approvers are @okta-groups/group1 (i.e. the bot user @project_xxxxx_bot1 has disappeared from the list.
    • [RESPOSITORY OWNER], allowed approvers are @okta-groups/group1
  6. If the user closes the existing MR and opens a new MR of the same feature branch, the CODEOWNERS approver list goes back to normal until the user pushes another commit.

No other merge request approval rules are set on the reposistory.

Example Project

N/A

What is the current bug behavior?

The bot user should not be dropped from approvers list on subsequent pushes after creating the MR.

What is the expected correct behavior?

The approvers list should not change after creating the MR as specified here

Relevant logs and/or screenshots

N/A

Output of checks

N/A

Results of GitLab environment info

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`)

We are running GitLab Enterprise Edition 14.8.5-ee. I don't have access to run the above commands. Will check with relevant team to see if they can do this.

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)

Do not have access to run this.

Possible fixes