From 0aaf6402f1dbfbdc0005e45186487f9e8b0bcfd3 Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Tue, 2 Dec 2025 22:28:54 +0100 Subject: [PATCH] revert: remove slugification from folder paths - Keep folder paths with spaces as-is, matching folder titles - Update test expectation to use 'Test Export Folder' instead of 'test-export-folder' - Remove unused slugify import - Folder paths should preserve original folder titles --- pkg/registry/apis/provisioning/jobs/export/resources.go | 7 ++----- pkg/tests/apis/provisioning/export_resources_test.go | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/registry/apis/provisioning/jobs/export/resources.go b/pkg/registry/apis/provisioning/jobs/export/resources.go index ca092d637d7..30d69cd3893 100644 --- a/pkg/registry/apis/provisioning/jobs/export/resources.go +++ b/pkg/registry/apis/provisioning/jobs/export/resources.go @@ -15,7 +15,6 @@ 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" ) @@ -358,12 +357,10 @@ 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, slugifiedPath) + exportPath = safepath.Join(exportPath, fid.Path) } else { - exportPath = slugifiedPath + exportPath = fid.Path } } } diff --git a/pkg/tests/apis/provisioning/export_resources_test.go b/pkg/tests/apis/provisioning/export_resources_test.go index 2079fc135fa..136ba38264f 100644 --- a/pkg/tests/apis/provisioning/export_resources_test.go +++ b/pkg/tests/apis/provisioning/export_resources_test.go @@ -230,7 +230,7 @@ func TestIntegrationProvisioning_ExportSpecificResourcesRejectsManagedResources( "exportunifiedtorepository/dashboard-test-v1.yaml": "dashboard.json", }, ExpectedDashboards: 1, - ExpectedFolders: 1, // Folder target creates a folder with the repo name + ExpectedFolders: 1, // Folder target creates a folder with the repo name SkipResourceAssertions: true, // Skip assertions since we're testing export, not sync } helper.CreateRepo(t, testRepo) @@ -366,8 +366,8 @@ func TestIntegrationProvisioning_ExportSpecificResourcesWithFolderStructure(t *t // Verify dashboard was exported with folder structure // The folder path should be included in the file path based on the folder title - // Folder title is "Test Export Folder", which gets slugified to "test-export-folder" - expectedFile := filepath.Join(helper.ProvisioningPath, "test-export-folder", "test-dashboard-created-at-v1.json") + // Folder title is "Test Export Folder", which is used as-is (with spaces) + expectedFile := filepath.Join(helper.ProvisioningPath, "Test Export Folder", "test-dashboard-created-at-v1.json") body, err := os.ReadFile(expectedFile) //nolint:gosec require.NoError(t, err, "exported file should exist with folder structure") obj := map[string]any{}