Existing namespace called "ghost" prevents creation of Ghost user
Summary
The Ghost user is used to ensure records are still attributed to a valid user record once the a user account is deleted. The ghost
method in User model ensures that the Ghost user is created if it doesn't already exist. If there is already a namespace called ghost
, and the User model's ghost
method is called, it results in a PostgreSQL error:
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_routes_on_path")
DETAIL: Key (path)=(ghost) already exists.
Steps to reproduce
Reproduced on self-managed v14.10.x and v15.0.0
- Ensure the Ghost user is not yet created on a self-managed instance
- Create a group called
ghost
- Attempt to delete a user, or execute
User.ghost
in the Rails console
Example Project
What is the current bug behavior?
User is not deleted, and Ghost user cannot be created. Error in Sidekiq logs for DeleteUserWorker
:
...
"error_message": "PG::UniqueViolation: ERROR: duplicate key value violates unique constraint \"index_routes_on_path\"\nDETAIL: Key (path)=(ghost) already exists.\n",
"error_class": "ActiveRecord::RecordNotUnique",
...
What is the expected correct behavior?
ghost
should be a reserved word. Top-level groups should not be allowed to be created with the name ghost
.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) ``` System information System: Ubuntu 20.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.5p203 Gem Version: 3.1.4 Bundler Version:2.2.33 Rake Version: 13.0.6 Redis Version: 6.2.6 Sidekiq Version:6.4.0 Go Version: unknown GitLab information Version: 14.10.0-ee Revision: ad109bc62af Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: https://omnibus-instance-20220529220910.f7f6ce3c.gcp.gitlabsandbox.net HTTP Clone URL: https://omnibus-instance-20220529220910.f7f6ce3c.gcp.gitlabsandbox.net/some-group/some-project.git SSH Clone URL: git@omnibus-instance-20220529220910.f7f6ce3c.gcp.gitlabsandbox.net:some-group/some-project.git Elasticsearch: yes Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.25.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell ```
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)