From 1bb954fdba0b2b9e09e35c384b98e83a195dcc6b Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Fri, 22 Aug 2025 12:57:07 +0000 Subject: [PATCH] fix: handle empty webhook templates properly (addresses #341) When a webhook has an empty template string, don't try to use it - fall through to the service-specific template instead. This was causing Discord webhooks to send empty payloads resulting in errors. --- internal/notifications/notifications.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go index f5fa966ae..f459b3c0a 100644 --- a/internal/notifications/notifications.go +++ b/internal/notifications/notifications.go @@ -431,7 +431,8 @@ func (n *NotificationManager) sendGroupedWebhook(webhook WebhookConfig, alertLis var err error // Check if webhook has a custom template first - if webhook.Template != "" && len(alertList) > 0 { + // Only use custom template if it's not empty + if webhook.Template != "" && strings.TrimSpace(webhook.Template) != "" && len(alertList) > 0 { // Use custom template with enhanced message for grouped alerts alert := alertList[0] if len(alertList) > 1 { @@ -684,7 +685,8 @@ func (n *NotificationManager) sendWebhook(webhook WebhookConfig, alert *alerts.A var err error // Check if webhook has a custom template first - if webhook.Template != "" { + // Only use custom template if it's not empty + if webhook.Template != "" && strings.TrimSpace(webhook.Template) != "" { // Use custom template provided by user enhanced := EnhancedWebhookConfig{ WebhookConfig: webhook,