Protected Branches/Tags error when adding a Maintainer role after a deploy key

Summary

Protected Branches and Tags encounter an error when attempting to add the Maintainer role after adding a Deploy Key. This is because they both have the same access_level value of 40.

Steps to reproduce

  • Create a new project
  • Navigate to Settings > Repository
  • Expand Deploy keys and add a deploy key
  • Expand Protected branches
    • Open the Allowed to push and merge dropdown
      • Remove Maintainers and close the dropdown to save
      • Add the deploy key and close the dropdown to save
      • Add the Maintainers role and close the dropdown to save
    • Observe the error
  • Expand Protected tags
    • Open the Allowed to create dropdown
      • Remove Maintainers and close the dropdown to save
      • Add the deploy key and close the dropdown to save
      • Add the Maintainers role and close the dropdown to save
    • Observe the error

Example Project

https://gitlab.com/gitlab-gold/jiocastillo/test-project/-/settings/repository#js-protected-branches-settings

What is the current bug behavior?

Protected branches

  • The user receives Failed to update branch! alert.
  • The browser receives a 422 status code with the following response:
    • {"push_access_levels.access_level":["has already been taken"]}

Protected tags

  • The user receives Failed to update tag! alert.
  • The browser receives a 422 status code with the following response:
    • {"create_access_levels.access_level":["has already been taken"]}

What is the expected correct behavior?

The Maintainer role can be added as expected.

Possible fixes