Folder+Dashboard: Resolve parent folders as service in search (#100185)

Resolve parent folders as service to guarantee that we can fetch the title
This commit is contained in:
Karl Persson
2025-02-06 16:40:07 +01:00
committed by GitHub
parent 1bf53e7a5f
commit 126396399e
@@ -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