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

pull/33880/head
Owen Diehl 4 years ago committed by GitHub
parent 81b8e6c13a
commit e18ca8f6f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      pkg/services/ngalert/api/forked_am.go

@ -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)
}

Loading…
Cancel
Save