The official Discourse Slack plugin’s /discourse Slack commands are broken in the latest version. mcwumbly reported the issue, providing logs showing a 500 Internal Server Error due to a routing error. The problem is related to the plugin’s authentication mechanism. vinothkannans suggested skipping the redirect_to_login_if_required before filter, and mcwumbly confirmed that this fix works. david mentioned implementing a similar solution in the Telegram plugin. tgxworld has since fixed the issue in the plugin, adding a test case to prevent future regressions.
I just updated the slack plugin on our instance to the latest version (compare versions), and it appears the /discourse slack commands are now broken:
Here’s what I see in the logs on our instance:
Started POST "/slack/command" for 52.91.184.228 at 2017-04-08 15:07:59 +0000
Processing by DiscourseSlack::SlackController#command as HTML
Parameters: {"token"=>"REDACTED", "team_id"=>"REDACTED", "team_domain"=>"mydomain", "channel_id"=>"REDACTED", "channel_name"=>"discourse-test", "user_id"=>"REDACTED", "user_name"=>"someuser", "command"=>"/discourse", "text"=>"help", "response_url"=>"https://hooks.slack.com/commands/FOO/BAR/bazbazbaz"}
Redirected to
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms)
ActionController::UrlGenerationError (No route matches {:action=>"enter", :controller=>"static"})
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/formatter.rb:46:in `generate'
Yup I think I removed one of the monkey patches. For the /command path, we need to skip everything because the only authentication we need to do is to check if the Slack token is valid.
This is exactly what I’ve done in my Telegram plugin (which is very similar to slack in the way the webhooks work). If there’s a better solution I’d be interested to know!
and added a test case for it. I’ve been involved in refactoring of the plugin but without existing test cases, there is a higher chance of me breaking stuff without knowing. Feel free to report any more bugs that you come across and I’ll get them sorted.