From 56f75a76f7391646a8cddbd85d1783b8299c084d Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Thu, 11 Jan 2024 12:40:22 +1100 Subject: [PATCH] fix: return error when no matching event to prevent empty email notifications --- .../logs2notifications/internal/handler/email_events.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/logs2notifications/internal/handler/email_events.go b/services/logs2notifications/internal/handler/email_events.go index 3e16e85fd9..f26c19e463 100644 --- a/services/logs2notifications/internal/handler/email_events.go +++ b/services/logs2notifications/internal/handler/email_events.go @@ -60,7 +60,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s if err != nil { eventSplit := strings.Split(notification.Event, ":") if eventSplit[0] != "problem" { - return "", "", "", "", "", nil + return "", "", "", "", "", fmt.Errorf("no matching event") } if eventSplit[1] == "insert" { tpl = "problemNotification" @@ -127,7 +127,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s case "problemNotification": eventSplit := strings.Split(notification.Event, ":") if eventSplit[0] != "problem" && eventSplit[1] == "insert" { - return "", "", "", "", "", nil + return "", "", "", "", "", fmt.Errorf("no matching event") } mainHTMLTpl = `[{{.ProjectName}}] New problem found for {{.EnvironmentName}}