From 4f292a3ecdabcdb9ee67c0d104997a21f3bf9b49 Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Tue, 2 Dec 2025 22:27:07 +0100 Subject: [PATCH] fix(export): slugify folder paths in computeExportPath - Slugify folder paths when computing export path to match file system conventions - Folder titles from DirPath need to be slugified before use in file paths - This fixes the folder structure export test --- pkg/registry/apis/provisioning/jobs/export/resources.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/registry/apis/provisioning/jobs/export/resources.go b/pkg/registry/apis/provisioning/jobs/export/resources.go index 30d69cd3893..ca092d637d7 100644 --- a/pkg/registry/apis/provisioning/jobs/export/resources.go +++ b/pkg/registry/apis/provisioning/jobs/export/resources.go @@ -15,6 +15,7 @@ import ( "github.com/grafana/grafana/apps/provisioning/pkg/repository" "github.com/grafana/grafana/apps/provisioning/pkg/safepath" "github.com/grafana/grafana/pkg/apimachinery/utils" + "github.com/grafana/grafana/pkg/infra/slugify" "github.com/grafana/grafana/pkg/registry/apis/provisioning/jobs" "github.com/grafana/grafana/pkg/registry/apis/provisioning/resources" ) @@ -357,10 +358,12 @@ func computeExportPath(basePath string, meta utils.GrafanaMetaAccessor, tree res // Get the folder path from the unmanaged tree (rootFolder is empty string for unmanaged tree) fid, ok := tree.DirPath(resourceFolder, "") if ok && fid.Path != "" { + // Slugify the folder path to match file system conventions + slugifiedPath := slugify.Slugify(fid.Path) if exportPath != "" { - exportPath = safepath.Join(exportPath, fid.Path) + exportPath = safepath.Join(exportPath, slugifiedPath) } else { - exportPath = fid.Path + exportPath = slugifiedPath } } }