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.
This commit is contained in:
Pulse Monitor
2025-08-22 12:57:07 +00:00
parent 2c755b03d5
commit 1bb954fdba
+4 -2
View File
@@ -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,