From 58352296a42cc167cf77fcabea838789e2590036 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 6 Oct 2023 12:08:38 +0200 Subject: [PATCH] [executor] Prevent crash on bad incoming message --- executor/handlers.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/executor/handlers.go b/executor/handlers.go index d1b5114a..4ad30f26 100644 --- a/executor/handlers.go +++ b/executor/handlers.go @@ -180,11 +180,17 @@ func handleMessageEvent(state *internalState, data []byte) (err error) { var cmd *executorcmd.ExecutorCommand_Transition cmd, err = activeTask.UnmarshalTransition(data) if err != nil { - log.WithFields(logrus.Fields{ - "name": cmd.Name, - "message": string(data[:]), - "error": err.Error(), - }). + fields := logrus.Fields{ + "error": err.Error(), + } + if cmd != nil { + fields["name"] = cmd.Name + } + if len(data) > 0 { + fields["message"] = string(data[:]) + } + + log.WithFields(fields). Error("cannot unmarshal incoming MESSAGE") return }