slack-ruby / slack-ruby-bot-server-events

Slack commands, interactive buttons, and events extension for slack-ruby-bot-server.
MIT License
71 stars 10 forks source link

Action request fails when payload is missing action_ids #8

Closed nijave closed 3 years ago

nijave commented 3 years ago

Given a message like this:

{
   "type":"message_action",
   "token":"abc",
   "action_ts":"1611349656.471151",
   "team":{
      "id":"abc",
      "domain":"nick-slack-test"
   },
   "user":{
      "id":"abc",
      "username":"nick",
      "team_id":"abc",
      "name":"nick"
   },
   "channel":{
      "id":"abc",
      "name":"development"
   },
   "is_enterprise_install":false,
   "enterprise":null,
   "callback_id":"triage",
   "trigger_id":"1673384558516.1660157428710.c9f7c48d8ccbfd3e7ea65c379be11a32",
   "response_url":"https://hooks.slack.com/app/...",
   "message_ts":"1611348347.001000",
   "message":{
      "client_msg_id":"5c18444f-27b2-4da4-b824-7dabbfa053e5",
      "type":"message",
      "text":"hello",
      "user":"abc",
      "ts":"1611348347.001000",
      "team":"abc",
      "blocks":[
         {
            "type":"rich_text",
            "block_id":"YF0te",
            "elements":[
               {
                  "type":"rich_text_section",
                  "elements":[
                     {
                        "type":"text",
                        "text":"hello"
                     }
                  ]
               }
            ]
         }
      ],
      "thread_ts":"1611348347.001000",
      "reply_count":1,
      "reply_users_count":1,
      "latest_reply":"1611348368.001100",
      "reply_users":[
         "abc"
      ],
      "subscribed":true,
      "last_read":"1611348368.001100"
   }
}
15:58:21 web.1  | E, [2021-01-22T15:58:21.605940 #2767726] ERROR -- : TypeError: no implicit conversion of nil into Array
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/slack-ruby-bot-server-events-0.3.0/lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb:79:in `+'
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/slack-ruby-bot-server-events-0.3.0/lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb:79:in `block in <class:ActionsEndpoint>'
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/grape-1.5.1/lib/grape/endpoint.rb:59:in `call'
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/grape-1.5.1/lib/grape/endpoint.rb:59:in `block (2 levels) in generate_api_method'
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:182:in `instrument'
15:58:21 web.1  |   /home/nick/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/grape-1.5.1/lib/grape/endpoint.rb:58:in `block in generate_api_method'

So it looks like the code expects that value might be missing since it has safe navigator but later it tries to use the value like an Array anyway

crazyoptimist commented 3 years ago

Thanks @nijave !