From 126396399e2fe485da63fde580d3003fbbf9e451 Mon Sep 17 00:00:00 2001 From: Karl Persson <23356117+kalleep@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:40:07 +0100 Subject: [PATCH] Folder+Dashboard: Resolve parent folders as service in search (#100185) Resolve parent folders as service to guarantee that we can fetch the title --- pkg/services/dashboards/service/dashboard_service.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index efbd0787a45..ac0a3504f9f 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -1249,13 +1249,17 @@ func (dr *DashboardServiceImpl) FindDashboards(ctx context.Context, query *dashb finalResults := make([]dashboards.DashboardSearchProjection, len(response.Hits)) // Create a small runtime cache for folders to avoid extra calls to the folder service foldersMap := make(map[string]*folder.Folder) + serviceCtx, serviceIdent := identity.WithServiceIdentity(ctx, query.OrgId) for i, hit := range response.Hits { f, ok := foldersMap[hit.Folder] if !ok { - f, err = dr.folderService.Get(ctx, &folder.GetFolderQuery{ + // We can get search result where user don't have access to parents. If that happens this thi + // will fail if we call it as the requesting user. To resolve this we call this as the service so we can + // garantuee that we can fetch the parent. + f, err = dr.folderService.Get(serviceCtx, &folder.GetFolderQuery{ UID: &hit.Folder, OrgID: query.OrgId, - SignedInUser: query.SignedInUser, + SignedInUser: serviceIdent, }) if err != nil { return nil, err