Fix crash on empty command in mattermost integration #326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ISSUE TYPE
SUMMARY
This should fix panic on empty command.
Bot will send the default message for the executor Platform (in my case its mattermost)
What did you do?
Sent empty command to botkube via mattermost (type @botkube)
What did you expect to see?
or at least nothing
What did you see?
panic: runtime error: index out of range [0] with length 0 goroutine 28 [running]: github.com/infracloudio/botkube/pkg/execute.(*DefaultExecutor).Execute(0xc000a11020, 0x0, 0x0) go/src/github.com/gohumble/botkube/pkg/execute/executor.go:191 +0xe13 github.com/infracloudio/botkube/pkg/bot.(*mattermostMessage).handleMessage(0xc000b75de8, 0xc0003d1940, 0x1a, 0xc00046b7c0, 0x5, 0xc00046b7cc, 0x4, 0xc00046b120, 0xd, 0x1, ...) go/src/github.com/gohumble/botkube/pkg/bot/mattermost.go:154 +0x54e github.com/infracloudio/botkube/pkg/bot.MMBot.listen(0xc0003d1940, 0x1a, 0xc00046b7c0, 0x5, 0xc00046b7cc, 0x4, 0xc00046b120, 0xd, 0x1, 0xc0003d1880, ...) go/src/github.com/gohumble/botkube/pkg/bot/mattermost.go:253 +0x4d1 github.com/infracloudio/botkube/pkg/bot.(*MMBot).Start.func1(0xc00058f4d0) go/src/github.com/gohumble/botkube/pkg/bot/mattermost.go:125 +0x2c7 created by github.com/infracloudio/botkube/pkg/bot.(*MMBot).Start src/github.com/gohumble/botkube/pkg/bot/mattermost.go:113 +0x712 Exiting.