Alerting: Fix misleading status code in provisioning API (#67331)

Fixes #66249
This commit is contained in:
Uwe Sommerlatt
2023-04-27 09:25:34 +01:00
committed by GitHub
parent dd6cda1511
commit dfc99cdd19
2 changed files with 11 additions and 0 deletions
@@ -266,6 +266,9 @@ func (srv *ProvisioningSrv) RouteGetAlertRules(c *contextmodel.ReqContext) respo
func (srv *ProvisioningSrv) RouteRouteGetAlertRule(c *contextmodel.ReqContext, UID string) response.Response {
rule, provenace, err := srv.alertRules.GetAlertRule(c.Req.Context(), c.OrgID, UID)
if err != nil {
if errors.Is(err, alerting_models.ErrAlertRuleNotFound) {
return response.Empty(http.StatusNotFound)
}
return ErrResp(http.StatusInternalServerError, err, "")
}
return response.JSON(http.StatusOK, ProvisionedAlertRuleFromAlertRule(rule, provenace))