mattermost: Custom slashcommand receives http error 500 from gitlab
Summary
Custom slashcommand added using the mattermost gitlab plugin receives http error 500.
Steps to reproduce
Follow the instructions on mattermost docs
What is the current bug behavior?
Custom slashcommand does not work, mattermost show this error message:
Command with a trigger of 'gitlab-test' returned response 500 Internal Server Error.
What is the expected correct behavior?
Custom slashcommand is successfully executed, in this case the help message should be displayed.
Relevant logs and/or screenshots
Processing by Gitlab::RequestForgeryProtection::Controller#index as JSON
Parameters: {"channel_id"=>"<redacted>", "channel_name"=>"server-config", "command"=>"/gitlab-test", "response_url"=>"https://x.xxx.xxx/hooks/commands/<redacted>", "team_domain"=>"<redacted>", "team_id"=>"<redacted>", "text"=>"[FILTERED]", "token"=>"[FILTERED]", "trigger_id"=>"YjdmZG54bjEzZm5leGRuZ2RhNHNkNnV4Y2U6ZjdoenBqcm9xM25mdGVzdG5oZzN3cGppenk6MTU5MTQzNjE1NDI4MTpNRVVDSUJ2VFZpb1VUK2tDT3h4UE9janY3RHZVWFhpd0RWUldzaURkZ3RxdCtuWmpBaUVBaDY5cHBMdW9taVNSa04yY2R2ZzIwYTFnVlhPbllrWVc0bUdHMFV3NVdaQT0=", "user_id"=>"<redacted>", "user_name"=>"<redacted>"}
Can't verify CSRF token authenticity.
This CSRF token verification failure is handled internally by `GitLab::RequestForgeryProtection`
Unlike the logs may suggest, this does not result in an actual 422 response to the user
For API requests, the only effect is that `current_user` will be `nil` for the duration of the request
Completed 422 Unprocessable Entity in 0ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms | Allocations: 233)
NameError (undefined local variable or method `footer' for #<Gitlab::SlashCommands::Presenters::Help:0x00007f90d1a812e0>):
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/slash_commands/presenters/help.rb:24:in `help_message'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/slash_commands/presenters/help.rb:13:in `present'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/slash_commands/help.rb:24:in `execute'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/slash_commands/command.rb:30:in `execute'
/opt/gitlab/embedded/service/gitlab-rails/app/models/project_services/slash_commands_service.rb:45:in `trigger'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/instrumentation.rb:161:in `block in trigger'
/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 `trigger'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3/lib/active_support/core_ext/object/try.rb:15:in `public_send'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3/lib/active_support/core_ext/object/try.rb:15:in `try'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/services.rb:159:in `block (3 levels) in <class:Services>'
Output of checks
self-hosted GitLab Community Edition 13.0.5
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.6.6p146 Gem Version: 2.7.10 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 5.0.9 Git Version: 2.26.2 Sidekiq Version:5.2.7 Go Version: unknown GitLab information Version: 13.0.5 Revision: 9097f912ba5 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 11.7 URL: https://gitlab..de HTTP Clone URL: https://gitlab..de/some-group/some-project.git SSH Clone URL: ssh://git@gitlab..de:2222/some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.2.0 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories 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
Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.2.0 ? ... OK (13.2.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: 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: ... Checking Reply by email ...
IMAP server credentials are correct? ... yes Init.d configured correctly? ... skipped MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
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: ... 5/1 ... yes 5/2 ... yes 5/3 ... yes 3/5 ... yes 3/6 ... yes 3/7 ... yes 6/9 ... yes 3/10 ... yes 6/11 ... yes 3/12 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.6) Git version >= 2.22.0 ? ... yes (2.26.2) Git user has default SSH configuration? ... yes Active users: ... 6 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... no Try fixing it: Please migrate all projects to hashed storage as legacy storage is deprecated in 13.0 and support will be removed in 14.0. For more information see: doc/administration/repository_storage_types.md
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Change footer
into help_footer
at https://gitlab.com/gitlab-org/.../help.rb#L24
I actually tried this in my docker container and now the error message is gone and the help text shown correctly.