enforce receivers align with backend type when posting AM config (#33877)

This commit is contained in:
Owen Diehl
2021-05-10 16:58:41 -04:00
committed by GitHub
parent 81b8e6c13a
commit e18ca8f6f2
+19
View File
@@ -117,6 +117,25 @@ func (am *ForkedAMSvc) RoutePostAlertingConfig(ctx *models.ReqContext, body apim
return response.Error(400, err.Error(), nil)
}
backendType, err := backendType(ctx, am.DatasourceCache)
if err != nil {
return response.Error(400, err.Error(), nil)
}
payloadType := body.AlertmanagerConfig.Type()
if backendType != payloadType {
return response.Error(
400,
fmt.Sprintf(
"unexpected backend type (%v) vs payload type (%v)",
backendType,
payloadType,
),
nil,
)
}
return s.RoutePostAlertingConfig(ctx, body)
}