slack-go / slack

Slack API in Go, originally by @nlopes; Maintainers needed, contact @parsley42
https://pkg.go.dev/github.com/slack-go/slack
BSD 2-Clause "Simplified" License
4.66k stars 1.14k forks source link

Release 0.21.4 breaks slash commands in socket mode #1265

Closed kpaulisse closed 7 months ago

kpaulisse commented 7 months ago

What happened

As of version 0.21.4, Slash commands do not work correctly in socket mode (resulting in "dispatch failed" in the client). This is a regression since version 0.21.3.

Expected behavior

Slash commands should work correctly in all versions.

Steps to reproduce

When using Socket mode on a non-enterprise instance, this is the payload when typing /mycommand foobar (with lots of redactions):

{
    "envelope_id": "e16988f4-ac45-4b4a-93b4-1851a6f77e6d",
    "payload": {
        "token": "XXX",
        "team_id": "T0000000000",
        "team_domain": "my-workspace",
        "channel_id": "C000000000000",
        "channel_name": "my-channel",
        "user_id": "U0000000000",
        "user_name": "My name here",
        "command": "/mycommand",
        "text": "foobar",
        "api_app_id": "A000000000",
        "is_enterprise_install": "false",
        "response_url": "https://hooks.slack.com/commands/A000000000/00000/XXXXX",
        "trigger_id": "00000.00000.00000"
    },
    "type": "slash_commands",
    "accepts_response_payload": true
}

The problem here is that https://github.com/slack-go/slack/pull/1255 adds a new IsEnterpriseInstall field with type boolean, whereas in the payload this is a string (e.g. "false"). Therefore the parsing of the JSON fails and the slash command handlers don't ever get invoked.

reproducible code

manifest.yaml

Versions