Alerting: Return proper status code when trying to create alert notification channel with duplicate name or uid (#28043)

* Alerting: Return proper status code when trying to create an Alert Notification where the name or UID already exists.

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
jgulick48
2020-10-20 06:53:48 -05:00
committed by GitHub
parent d13c6b4c5a
commit 5bc6c447e3
3 changed files with 8 additions and 2 deletions

View File

@@ -299,7 +299,7 @@ func CreateAlertNotificationCommand(cmd *models.CreateAlertNotificationCommand)
}
if existingQuery.Result != nil {
return fmt.Errorf("Alert notification uid %s already exists", cmd.Uid)
return models.ErrAlertNotificationWithSameUIDExists
}
// check if name exists
@@ -309,7 +309,7 @@ func CreateAlertNotificationCommand(cmd *models.CreateAlertNotificationCommand)
}
if sameNameQuery.Result != nil {
return fmt.Errorf("Alert notification name %s already exists", cmd.Name)
return models.ErrAlertNotificationWithSameNameExists
}
var frequency time.Duration