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.6k stars 1.11k forks source link

Parse string or boolean for SlashCommand.IsEnterpriseInstall #1266

Closed kpaulisse closed 4 months ago

kpaulisse commented 4 months ago

This PR adds a custom JSON parser for the SlashCommand struct to work correctly when "is_enterprise_install" comes in as either a string or a boolean. As noted in the issue, in socket mode, certain (but not all 🤷) payloads have "is_enterprise_install" as a quoted boolean (e.g. "false") whereas others have it as an actual boolean (e.g. false).

This doesn't update the IsEnterpriseInstall field in SlashCommand itself, so this change should be transparent to anyone who might have started using that newly added field.

Fixes https://github.com/slack-go/slack/issues/1265 Prior fix attempt: https://github.com/slack-go/slack/pull/1264

Testing:

  1. Added unit test covering happy paths and error cases
  2. My application works correctly pointing at this branch