Merge request approval APIs return inconsistent approvals_required
Summary
The approval_rules
REST endpoint returns 0 required_approvals
for required Codeowners rules when approval_state and GraphQL returns 1.
Steps to reproduce
- Create an MR that has a required code owner approval: !86148 (merged)
- Request the
approval_rules
endpoint: https://gitlab.com/api/v4/projects/278964/merge_requests/86148/approval_rules - Find the code owner approval rule
Example Project
What is the current bug behavior?
The approvals_required
attribute is 0
What is the expected correct behavior?
The approvals_required
attribute is 1 if the code owner rule is non-optional and require approvals is turned on for protected branches
Relevant logs and/or screenshots
https://gitlab.com/api/v4/projects/278964/merge_requests/86148/approval_state shows approvals_required
= 1
This GraphQL query returns 1 for approvalsRequired:
query{
project(fullPath: "gitlab-org/gitlab") {
mergeRequests(iids: ["86148"]) {
edges {
node {
title
approvalState {
rules {
id
name
approvalsRequired
approved
groups {
nodes {
fullName
fullPath
}
}
}
}
}
}
}
}
}
Output of checks
This bug happens on GitLab.com
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`)
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)