Alerting: Fix updating notification channels in legacy (#45302) (#45331)

The problem here is that without the orgID we ignore the lookup of the existing notification channel just before updating and end up failing the update because there is no channel available.

(cherry picked from commit 8bf2e642aa)

Co-authored-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
Grot (@grafanabot)andgotjosh authored and GitHub committed 2022-02-16 13:35:39 +00:00
1 parent 5b73b4e070
commit 3179d548bb
1 file changed
+7 -1
+7 -1
View File
@@ -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 {