Role counter on protected branches does not work properly for No One.

Summary

No one can be added infinitely often to allowed to merge / allowed to push There is no way to reset the counter.

Steps to reproduce

Create a new repo. Go to Settings -> Repository -> Protected Branches Try to protect a branch, click on No one multiple times The roles counter increases with each click.

Example Project

https://gitlab.com/th0br0/repro-protected-bug

What is the current bug behavior?

No one can be added ad infinitum. This doesn't work when editing an already protected branch as that will error out with status code 422. The counter appears to persist across repos.

What is the expected correct behavior?

No one can only be added once. Removing No one decrements the counter.

Relevant logs and/or screenshots

roles

Output of checks

This bug happens on GitLab.com

Possible fixes

UI side (couldn't find exact location): https://gitlab.com/gitlab-org/gitlab-ee/tree/master/app/assets/javascripts/protected_branches Server side (should filter ids?): https://gitlab.com/gitlab-org/gitlab-ee/blob/master/lib/api/protected_branches.rb#L49

Assignee Loading
Time tracking Loading