From group inherited project members can't be given merge or push privileges on protected branch

Summary

Project members that are inherited from a group can't be given merge or push privileges on protected branches. The user gets a HTTP 422 as a response.

If the users that are supposed to be given access are added to the project directly as members, the protected branch privileges can be correctly set.

Steps to reproduce

  1. Create a group
  2. Create a project within the group and add at least one branch
  3. In the project settings under Repository > Protected Branches create a new protected branch, or edit the default one. Select one or more project members inherited from the group in Allowed to merge or Allowed to push (yourself will work).

What is the current bug behavior?

User gets a HTTP 422 error and the protected branch rule is not created/updated.

What is the expected correct behavior?

Protected branch rule should be created/updated with the selected push/merge privileges.

Relevant logs and/or screenshots

Sanitized and prettified entry from production_json.log:

{
   "format" : "json",
   "username" : "exampleuser",
   "response" : "{\"merge_access_levels.user\":[\"is not a member of the project\"],\"push_access_levels.user\":[\"is not a member of the project\"]}",
   "duration" : 143.1,
   "params" : [
      {
         "key" : "protected_branch",
         "value" : {
            "merge_access_levels_attributes" : [
               {
                  "access_level" : 40,
                  "id" : 123,
                  "_destroy" : "1"
               },
               {
                  "user_id" : 5
               },
               {
                  "user_id" : 6
               }
            ],
            "push_access_levels_attributes" : [
               {
                  "access_level" : 40,
                  "id" : 11752
               },
               {
                  "user_id" : 5
               },
               {
                  "user_id" : 6
               },
               {
                  "user_id" : 7
               }
            ]
         }
      },
      {
         "key" : "namespace_id",
         "value" : "example-group"
      },
      {
         "value" : "example-project",
         "key" : "project_id"
      },
      {
         "key" : "id",
         "value" : "456"
      }
   ],
   "status" : 422,
   "remote_ip" : "[REMOVED]",
   "correlation_id" : "1fsGc46WGY6",
   "time" : "2019-02-11T11:28:03.127Z",
   "method" : "PATCH",
   "controller" : "Projects::ProtectedBranchesController",
   "view" : 0.29,
   "path" : "/example-group/example-project/protected_branches/456",
   "db" : 40.79,
   "user_id" : 6,
   "ua" : "[REMOVED]",
   "action" : "update"
}

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		Debian 9.7
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.5.3p105
Gem Version:	2.7.6
Bundler Version:1.16.6
Rake Version:	12.3.2
Redis Version:	3.2.12
Git Version:	2.18.1
Sidekiq Version:5.2.3
Go Version:	unknown

GitLab information Version: 11.7.5-ee Revision: ed04633 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.11 URL: https://gitlab.example.com HTTP Clone URL: https://gitlab.example.com/some-group/some-project.git SSH Clone URL: git@gitlab.example.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: no

GitLab Shell Version: 8.4.4 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 8.4.4 ? ... OK (8.4.4) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Checking Reply by email ...

IMAP server credentials are correct? ... yes Init.d configured correctly? ... skipped MailRoom running? ... skipped

Checking Reply by email ... Finished

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) [REMOVED]

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... [ALL GREEN]

Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 2619 Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Assignee Loading
Time tracking Loading