Protected branches API fail

Hi guys.

I’m trying to configure my project protected branches using API with this request:

…/api/v4/projects/25/protected_branches

{
“name”: “master”,
“allowed_to_push”: [40],
“allowed_to_merge”: [30, 40]
}

Unfortunately, the response is

{
“message”: “500 Internal Server Error”
}

And these are the logs:

NoMethodError (undefined method `new' for Integer:Class):

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:51:in `declared_hash’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:38:in `declared’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:46:in `block in declared_array’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:45:in `map’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:45:in `declared_array’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:36:in `declared’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:62:in `block (3 levels) in declared_hash’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:88:in `handle_passed_param’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:61:in `block (2 levels) in declared_hash’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:53:in `each_pair’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:53:in `block in declared_hash’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:51:in `each’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:51:in `each_with_object’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:51:in `declared_hash’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/dsl/inside_route.rb:38:in `declared’

/opt/gitlab/embedded/service/gitlab-rails/lib/api/helpers.rb:18:in `declared_params’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/instrumentation.rb:161:in `block in declared_params’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/method_call.rb:36:in `measure’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/instrumentation.rb:161:in `declared_params’

/opt/gitlab/embedded/service/gitlab-rails/lib/api/protected_branches.rb:72:in `block (2 levels) in class:ProtectedBranches

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:59:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:59:in `block (2 levels) in generate_api_method’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/notifications.rb:182:in `instrument’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:58:in `block in generate_api_method’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:341:in `execute’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:267:in `block in run’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/notifications.rb:182:in `instrument’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:247:in `run’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:322:in `block in build_stack’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:35:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:28:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:35:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:28:in `call’

/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/middleware/ip_restrictor.rb:14:in `block in call’

/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ip_address_state.rb:10:in `with’

/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/middleware/ip_restrictor.rb:13:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:35:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:28:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-oauth2-1.9.3/lib/rack/oauth2/server/resource.rb:20:in `_call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-oauth2-1.9.3/lib/rack/oauth2/server/resource/bearer.rb:8:in `_call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-oauth2-1.9.3/lib/rack/oauth2/server/abstract/handler.rb:17:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/error.rb:39:in `block in call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/error.rb:38:in `catch’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/error.rb:38:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:28:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb:60:in `block in call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb:58:in `catch’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb:58:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/middleware/base.rb:28:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/head.rb:12:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:231:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/endpoint.rb:225:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router/route.rb:58:in `exec’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:116:in `process_route’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:72:in `block in identity’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:91:in `transaction’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:70:in `identity’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:55:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:132:in `with_optimization’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/router.rb:54:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/api/instance.rb:167:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/api/instance.rb:71:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/grape-1.4.0/lib/grape/api/instance.rb:66:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/routing/mapper.rb:19:in `block in class:Constraints

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/routing/mapper.rb:48:in `serve’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/journey/router.rb:49:in `block in serve’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/journey/router.rb:32:in `each’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/journey/router.rb:32:in `serve’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/routing/route_set.rb:834:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:192:in `call!’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/omniauth-1.9.0/lib/omniauth/strategy.rb:169:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/elasticsearch_rack_middleware.rb:24:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/redis_rack_middleware.rb:22:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/rails_queue_duration.rb:29:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/rack_middleware.rb:17:in `block in call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/transaction.rb:54:in `run’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/rack_middleware.rb:17:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/request_profiler/middleware.rb:17:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-labkit-0.12.1/lib/labkit/middleware/rack.rb:19:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-labkit-0.12.1/lib/labkit/context.rb:32:in `with_context’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-labkit-0.12.1/lib/labkit/middleware/rack.rb:18:in `call’

/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/jira/middleware.rb:19:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/go.rb:20:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/etag_caching/middleware.rb:13:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/batch-loader-1.4.0/lib/batch_loader/middleware.rb:11:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-attack-6.3.0/lib/rack/attack.rb:97:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/apollo_upload_server-2.0.0.beta.3/lib/apollo_upload_server/middleware.rb:20:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/multipart.rb:140:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-attack-6.3.0/lib/rack/attack.rb:111:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-cors-1.0.6/lib/rack/cors.rb:98:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/tempfile_reaper.rb:15:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/etag.rb:25:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/conditional_get.rb:38:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/head.rb:12:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/read_only/controller.rb:51:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/read_only.rb:18:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/session/abstract/id.rb:259:in `context’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/session/abstract/id.rb:253:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/cookies.rb:648:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/same_site_cookies.rb:27:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/callbacks.rb:101:in `run_callbacks’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/basic_health_check.rb:25:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb:37:in `call_app’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb:26:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb:80:in `block in tagged’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb:28:in `tagged’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/tagged_logging.rb:80:in `tagged’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/rack/logger.rb:26:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/request_context.rb:23:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/request_store-1.5.0/lib/request_store/middleware.rb:19:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/request_id.rb:27:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/method_override.rb:22:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/runtime.rb:22:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-timeout-0.5.2/lib/rack/timeout/core.rb:123:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-timeout-0.5.2/lib/rack/timeout/support/timeout.rb:19:in `timeout’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-timeout-0.5.2/lib/rack/timeout/core.rb:122:in `call’

/opt/gitlab/embedded/service/gitlab-rails/config/initializers/fix_local_cache_middleware.rb:9:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/executor.rb:14:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/sendfile.rb:111:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/actionpack-6.0.3.1/lib/action_dispatch/middleware/host_authorization.rb:76:in `call’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/requests_rack_middleware.rb:60:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/sentry-raven-2.9.0/lib/raven/integrations/rack.rb:51:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/engine.rb:527:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/railtie.rb:190:in `public_send’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/railtie.rb:190:in `method_missing’

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/middleware/release_env.rb:12:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/urlmap.rb:68:in `block in call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/urlmap.rb:53:in `each’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/rack-2.0.9/lib/rack/urlmap.rb:53:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/lib/puma/configuration.rb:228:in `call’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/lib/puma/server.rb:691:in `handle_request’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/lib/puma/server.rb:481:in `process_client’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/lib/puma/server.rb:335:in `block in run’

/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/gitlab-puma-4.3.3.gitlab.2/lib/puma/thread_pool.rb:138:in `block in spawn_thread’