enforce receivers align with backend type when posting AM config (#33877)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user