From 216185b7f069cb61b9201edfb6eca7f01ae30151 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Fri, 26 Aug 2022 15:09:56 -0700 Subject: [PATCH] Storage: Avoid UID errors from annotations api when loading dashboards from storage (#54346) --- pkg/api/annotations.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index 13cdbd923ad..0fdd3528635 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -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()