Error 500 when opening General settings of personal projects if Duo is disabled
Summary
Error 500 when opening General settings of personal projects if Duo is disabled at the instance level.
Steps to reproduce
- Disable Duo by setting
duo_features_enabledtofalseandlock_duo_features_enabledtotruevia Application Setting API. - Create a new project in a personal namespace, go to Settings > General.
What is the current bug behavior?
500 Error will be shown when trying to open Settings > General.
What is the expected correct behavior?
There should be no error when opening Settings > General.
Relevant logs and/or screenshots
Details of the error can be found in the production_json.log:
{
"method": "GET",
"path": "/root/test-tooltip/edit",
"format": "html",
"controller": "ProjectsController",
"action": "edit",
"status": 500,
"exception.class": "ActionView::Template::Error",
"exception.message": "undefined method `name' for nil:NilClass\n\n full_name: project.group.name,\n ^^^^^",
"exception.backtrace": [
"app/helpers/namespaces_helper.rb:76:in `update_project_data_with_lock_info'",
"app/helpers/namespaces_helper.rb:62:in `project_cascading_namespace_settings_tooltip_data'",
"app/helpers/projects_helper.rb:918:in `project_permissions_data'",
"app/views/projects/edit.html.haml:31",
"actionview (7.0.8.4) lib/action_view/helpers/capture_helper.rb:45:in `block in capture'",
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Debian 12 Proxy: no Current User: git Using RVM: no Ruby Version: 3.1.5p253 Gem Version: 3.5.17 Bundler Version:2.5.11 Rake Version: 13.0.6 Redis Version: 7.0.15 Sidekiq Version:7.2.4 Go Version: unknown GitLab information Version: 17.4.0-ee Revision: 22193b3da88 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 14.11 URL: https://gitlab-host.tld HTTP Clone URL: https://gitlab-host.tld/some-group/some-project.git SSH Clone URL: git@gitlab-host.tld:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.39.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Gitaly - default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 17.4.0 - default Git Version: 2.46.0
Possible fixes
The issue is the consequence of the merge request !163050 (merged).
In this code, we use project_permissions_data method that, in turn, uses project_cascading_namespace_settings_tooltip_data. In project_cascading_namespace_settings_tooltip_data, we call update_project_data_with_lock_info that tries to get project.group.name, and it is not available for projects in personal namespaces.
Workarounds
Workaround 1
Set lock_duo_features_enabled back to false.
Workaround 2
- Patch
/opt/gitlab/embedded/service/gitlab-rails/app/helpers/namespaces_helper.rbon your GitLab instance by modifying the lines according to the MR !167066 (diffs). - Restart GitLab to apply changes.
Edited by Alexandr Tanayno