From 559dab8b1b676fa692efa0c66dcdb0542f6a547f Mon Sep 17 00:00:00 2001 From: Moustafa Baiou Date: Tue, 11 Nov 2025 11:53:36 -0500 Subject: [PATCH] Alerting: Fix error when updating Alertmanager config with autogenerated receivers (#113710) If an alert rule with an invalid receiver is created it breaks the entire alertmanager configuration rather than preventing the save. This fixes the issue by erroring on save and apply, and logging invalid receivers only when applying the config after an update. Introduced in #111838 --- pkg/services/ngalert/notifier/alertmanager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/ngalert/notifier/alertmanager.go b/pkg/services/ngalert/notifier/alertmanager.go index dc2f63fb0ec..05e42a66b09 100644 --- a/pkg/services/ngalert/notifier/alertmanager.go +++ b/pkg/services/ngalert/notifier/alertmanager.go @@ -233,7 +233,7 @@ func (am *alertmanager) SaveAndApplyConfig(ctx context.Context, cfg *apimodels.P } err = am.Store.SaveAlertmanagerConfigurationWithCallback(ctx, cmd, func() error { - _, err = am.applyConfig(ctx, cfg, LogInvalidReceivers) // fail if the autogen config is invalid + _, err = am.applyConfig(ctx, cfg, ErrorOnInvalidReceivers) // fail if the autogen config is invalid return err }) if err != nil { @@ -259,7 +259,7 @@ func (am *alertmanager) ApplyConfig(ctx context.Context, dbCfg *ngmodels.AlertCo // Since we will now update last_applied when autogen changes even if the user-created config remains the same. // To fix this however, the local alertmanager needs to be able to tell the difference between user-created and // autogen config, which may introduce cross-cutting complexity. - configChanged, err := am.applyConfig(ctx, cfg, ErrorOnInvalidReceivers) + configChanged, err := am.applyConfig(ctx, cfg, LogInvalidReceivers) if err != nil { outerErr = fmt.Errorf("unable to apply configuration: %w", err) return