Storage: Avoid UID errors from annotations api when loading dashboards from storage (#54346)

This commit is contained in:
Ryan McKinley 2022-08-26 15:09:56 -07:00 committed by GitHub
parent a932428057
commit 216185b7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import (
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/annotations"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/user"
@ -52,9 +53,14 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
dq := models.GetDashboardQuery{Uid: query.DashboardUid, OrgId: c.OrgID}
err := hs.DashboardService.GetDashboard(c.Req.Context(), &dq)
if err != nil {
return response.Error(http.StatusBadRequest, "Invalid dashboard UID in the request", err)
if hs.Features.IsEnabled(featuremgmt.FlagDashboardsFromStorage) {
// OK... the storage UIDs do not (yet?) exist in the DashboardService
} else {
return response.Error(http.StatusBadRequest, "Invalid dashboard UID in annotation request", err)
}
} else {
query.DashboardId = dq.Result.Id
}
query.DashboardId = dq.Result.Id
}
repo := annotations.GetRepository()