From c997b88cbdf038b6a898c0d8b8e7301467dc3e2c Mon Sep 17 00:00:00 2001 From: nicufk Date: Wed, 14 Feb 2024 21:54:35 +0200 Subject: [PATCH] fix: nil pointer in compose slack message (#5011) --- pkg/slack/slack.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/slack/slack.go b/pkg/slack/slack.go index c6ab0f2734d..c2bdc74e5e6 100644 --- a/pkg/slack/slack.go +++ b/pkg/slack/slack.go @@ -221,17 +221,25 @@ func (s *Notifier) composeTestMessage(execution *testkube.Execution, eventType t Labels: testkube.MapToString(execution.Labels), TestName: execution.TestName, TestType: execution.TestType, - Status: string(*execution.ExecutionResult.Status), + Status: string(testkube.QUEUED_ExecutionStatus), StartTime: execution.StartTime.String(), EndTime: execution.EndTime.String(), Duration: execution.Duration, - TotalSteps: len(execution.ExecutionResult.Steps), - FailedSteps: execution.ExecutionResult.FailedStepsCount(), + TotalSteps: 0, + FailedSteps: 0, ClusterName: s.clusterName, DashboardURI: s.dashboardURI, Envs: s.envs, } + if execution.ExecutionResult != nil { + if execution.ExecutionResult.Status != nil { + args.Status = string(*execution.ExecutionResult.Status) + } + args.TotalSteps = len(execution.ExecutionResult.Steps) + args.FailedSteps = execution.ExecutionResult.FailedStepsCount() + } + log.DefaultLogger.Infow("Execution changed", "status", execution.ExecutionResult.Status) var message bytes.Buffer