ChatOps 500 error on chat_names after delete project

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

GitLab-ce omnibus-gitlab package version 11.9.10, following the documentation to create a ChatOps to project A. After creation, we can find the ChatOps project A in User's settings, then Chat(Active chat names).

But when the project A is Deleted, user can not add new ChatOps anymore, 500 error in page Chat (https://gitlab.example/profile/chat_names)

On server log, we can find nil error:

Started GET "/profile/chat_names" for 127.0.0.1 
Processing by Profiles::ChatNamesController#index as HTML
Completed 500 Internal Server Error in 113ms (ActiveRecord: 26.3ms)
  
ActionView::Template::Error (undefined method `project' for nil:NilClass):
    1: - service = chat_name.service
    2: - project = service.project
    3: %tr
    4:   %td
    5:     %strong

Steps to reproduce

  1. create a slash integration in mattermost with slack slash command for a project.
  2. check the creation on User's settings, on Chat page, new Chat names is listed
  3. remove the project
  4. check again Chat page, 500 error

What is the current bug behavior?

500 error on User's settings Chat page, user can not create new ChatOps

What is the expected correct behavior?

when delete a project, the related Chat names will disable with a tag or ask user to remove it

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:

System information System: Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.5 Go Version: unknown

GitLab information Version: 11.9.10 Revision: 6f5448d Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: XXXXX HTTP Clone URL: XXXXX SSH Clone URL: XXXXX Using LDAP: yes Using Omniauth: no

GitLab Shell Version: 8.7.1 Repository storage paths:

  • default: XXXXXX GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git

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:

Checking GitLab subtasks ... Checking GitLab Shell ... GitLab Shell: ... GitLab Shell version >= 8.7.1 ? ... OK (8.7.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK gitlab-shell self-check successful Checking GitLab Shell ... Finished Checking Gitaly ... Gitaly: ... default ... OK Checking Gitaly ... Finished Checking Sidekiq ... Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1 Checking Sidekiq ... Finished Checking Incoming Email ... Incoming Email: ... Reply by email is disabled in config/gitlab.yml Checking Incoming Email ... Finished Checking LDAP ... LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) Checking LDAP ... Finished Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 202

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

try to catch the nil on removed project here

Started GET "/profile/chat_names" for 127.0.0.1 
Processing by Profiles::ChatNamesController#index as HTML
Completed 500 Internal Server Error in 113ms (ActiveRecord: 26.3ms)
  
ActionView::Template::Error (undefined method `project' for nil:NilClass):
    1: - service = chat_name.service
    2: - project = service.project
    3: %tr
    4:   %td
    5:     %strong

Or user needs to delete the line which has the removed project service_id on datebase chatnames table

Edited by 🤖 GitLab Bot 🤖