From 7dab52983103a772b8d59777dabccce5b864cb2a Mon Sep 17 00:00:00 2001 From: Gary Kramlich Date: Wed, 21 Aug 2024 13:41:21 -0500 Subject: [PATCH] Fix parsing on older versions of salt On older versions of salt, the message body is already a string which causes the .([]byte) type assertion to fail. This catches that failure than then tries an .(string) assertion to handle both cases. --- pkg/parser/parser.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 3450c5b..62eea68 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -95,7 +95,13 @@ func statemoduleResult(event event.SaltEvent) *bool { // ParseEvent parses a salt event. func (e Event) Parse(message map[string]interface{}) (event.SaltEvent, error) { - body := string(message["body"].([]byte)) + var body string + + if raw, ok := message["body"].([]byte); ok { + body = string(raw) + } else { + body = message["body"].(string) + } lines := strings.SplitN(body, "\n\n", 2) tag := lines[0]