Closed talaniz closed 4 months ago
It worked for me if i change the value of struct SlashCommand to
type SlashCommand struct {
Token string `json:"token"`
TeamID string `json:"team_id"`
TeamDomain string `json:"team_domain"`
EnterpriseID string `json:"enterprise_id,omitempty"`
EnterpriseName string `json:"enterprise_name,omitempty"`
IsEnterpriseInstall bool `json:"is_enterprise_install,string"`
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
Command string `json:"command"`
Text string `json:"text"`
ResponseURL string `json:"response_url"`
TriggerID string `json:"trigger_id"`
APIAppID string `json:"api_app_id"`
}
Which should not be the case. but not sure.
Changed value IsEnterpriseInstall bool json:"is_enterprise_install"
-> IsEnterpriseInstall bool json:"is_enterprise_install,string"
Reference to line
https://github.com/slack-go/slack/blob/v0.12.4/slash.go#L14
Happened to me too
Same problem, rollback to v.0.12.3 is helped
slack-go/slack: v.0.12.4 go1.21.5 darwin/arm64
Event Data:
{parsing slash command: json: cannot unmarshal string into Go struct field SlashCommand.is_enterprise_install of type bool {"envelope_id":"XXXXX","payload":{"token":"XXXXX","team_id":"XXXXX","team_domain":"XXXX","channel_id":"XXXX","channel_name":"lolkek","user_id":"U0XXXXX","user_name":"XXXXX","command":"\/pollsettings","text":"","api_app_id":"XXXXX","is_enterprise_install":"false","response_url":"https:\/\/hooks.slack.com\/commands\/XXXXX\/XXXXXX\/XXXXXX","trigger_id":"XXXXXXX"},"type":"slash_commands","accepts_response_payload":true}}
Code sample:
func (s *Service) eventRouter(ctx context.Context, e socketmode.Event) error {
switch e.Type {
case socketmode.EventTypeSlashCommand:
s.slack.Ack(e.Request)
e := e.Data.(slack.SlashCommand)
switch e.Command {
case "/test":
return s.poll.CreateModalView(ctx, &e)
case "/pollsettings":
return s.poll.CreatePollSettingsModal(ctx, &e)
case "/pepefast":
return s.poll.CreateFast(ctx, &e)
}
case socketmode.EventTypeInteractive:
s.slack.Ack(e.Request)
e := e.Data.(slack.InteractionCallback)
switch {
case e.Type == slack.InteractionTypeViewSubmission && (e.View.CallbackID == "poll_modal_view" || e.View.CallbackID == "settings_modal_view"),
e.Type == slack.InteractionTypeBlockActions && e.View.CallbackID == "settings_modal_view",
e.Type == slack.InteractionTypeInteractionMessage && strings.Contains(e.CallbackID, "poll"):
return s.poll.Interactions(ctx, &e)
}
case socketmode.EventTypeErrorBadMessage:
fmt.Printf("%s", e.Data)
default:
if e.Type != "connecting" && e.Type != "connected" && e.Type != "hello" {
return errors.New(fmt.Sprintf("UNKNOW EVENT TYPE %s", e.Type))
}
}
return nil
}
Sorry about that; probably a straight-forward fix, somebody care to work up a PR? I added a comment to the PR where this was introduced.
Looks like there's one in that already addresses the comments on the original commit https://github.com/slack-go/slack/pull/1266
Just published v0.12.5 which deals w/ bool or string. Thanks to @kpaulisse.
I've tested in v0.12.5, looks like all is working. Thanks everyone!
What happened
I'm following this tutorial for creating a Slack bot in socket mode. I've created a very basic "hello" command and reinstalled the app. However, when I run the code and attempt the command "/hello reader" per the tutorial, I get "/hello failed with the error "dispatch_failed"" instead of processing the command. I tried adding a default case to the switch statement and it returns
****** Received Event: {error_bad_message 0x1400029e5d0 <nil>}
, which appears to come from the slack-go library.Sample websocket message
Expected behavior
It looks like the code should process the command correctly.
Steps to reproduce
Follow the tutorial to create the slash command (code below).
reproducible code
manifest.yaml
Versions