Fix issues with invalid Slack contact points (#41062)
* Add validation when creating/updating a contact point * Change 201 status code for 200 (as it was before)
This commit is contained in:
@@ -283,6 +283,10 @@ func CreateAlertNotification(c *models.ReqContext, cmd models.CreateAlertNotific
|
||||
if errors.Is(err, models.ErrAlertNotificationWithSameNameExists) || errors.Is(err, models.ErrAlertNotificationWithSameUIDExists) {
|
||||
return response.Error(409, "Failed to create alert notification", err)
|
||||
}
|
||||
var alertingErr alerting.ValidationError
|
||||
if errors.As(err, &alertingErr) {
|
||||
return response.Error(400, err.Error(), err)
|
||||
}
|
||||
return response.Error(500, "Failed to create alert notification", err)
|
||||
}
|
||||
|
||||
@@ -301,6 +305,10 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext, cmd models.U
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), err)
|
||||
}
|
||||
var alertingErr alerting.ValidationError
|
||||
if errors.As(err, &alertingErr) {
|
||||
return response.Error(400, err.Error(), err)
|
||||
}
|
||||
return response.Error(500, "Failed to update alert notification", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user