Skip to content

Cannot delete Deploy Keys as an administrator

Summary

The deploy keys and the delete button are visible to administrators. But when attempting to delete you are presented with an Error removing deploy key message.

err

Steps to reproduce

  • Create a Project as a non-admin user

  • Add a deploy key to that project

  • Switch to an admin account (without permissions on the project)

  • attempt to delete the deploy key

What is the current bug behavior?

Key doesn't delete and throws error and exception:

ActiveRecord::RecordNotFound (Couldn't find DeployKey with 'id'=2 [WHERE "keys"."type" IN ('DeployKey') AND 1=0]):
  app/controllers/projects/deploy_keys_controller.rb:104:in `load_key'
  app/controllers/projects/deploy_keys_controller.rb:66:in `disable'
  lib/gitlab/i18n.rb:53:in `with_locale'
  lib/gitlab/i18n.rb:59:in `with_user_locale'
  app/controllers/application_controller.rb:432:in `set_locale'
  lib/gitlab/middleware/multipart.rb:101:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  ee/lib/gitlab/jira/middleware.rb:15:in `call'
  lib/gitlab/middleware/go.rb:17:in `call'
  lib/gitlab/etag_caching/middleware.rb:11:in `call'
  lib/gitlab/middleware/rails_queue_duration.rb:22:in `call'
  lib/gitlab/metrics/rack_middleware.rb:15:in `block in call'
  lib/gitlab/metrics/transaction.rb:53:in `run'
  lib/gitlab/metrics/rack_middleware.rb:15:in `call'
  lib/gitlab/middleware/read_only/controller.rb:40:in `call'
  lib/gitlab/middleware/read_only.rb:16:in `call'
  lib/gitlab/middleware/basic_health_check.rb:25:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
  lib/gitlab/middleware/release_env.rb:10:in `call'

What is the expected correct behavior?

Delete the DeployKey

Reproduced on 10.8.7 and 11.4.5