diff --git a/pkg/services/alerting/service.go b/pkg/services/alerting/service.go index a648950b7a2..2d055feac34 100644 --- a/pkg/services/alerting/service.go +++ b/pkg/services/alerting/service.go @@ -2,6 +2,7 @@ package alerting import ( "context" + "fmt" "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/models" @@ -74,6 +75,7 @@ func (s *AlertNotificationService) UpdateAlertNotification(ctx context.Context, model := models.AlertNotification{ Id: cmd.Id, + OrgId: cmd.OrgId, Name: cmd.Name, Type: cmd.Type, Settings: cmd.Settings, @@ -134,7 +136,11 @@ func (s *AlertNotificationService) createNotifier(ctx context.Context, model *mo return nil, err } - if query.Result != nil && query.Result.SecureSettings != nil { + if query.Result == nil { + return nil, fmt.Errorf("unable to find the alert notification") + } + + if query.Result.SecureSettings != nil { var err error secureSettingsMap, err = s.EncryptionService.DecryptJsonData(ctx, query.Result.SecureSettings, setting.SecretKey) if err != nil {