From ff4f2b39263473034d387e6d02d901a9e2253552 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 2 Dec 2025 14:22:46 +0300 Subject: [PATCH] remove general folder in legacy api --- pkg/services/dashboards/service/dashboard_service.go | 7 ++++++- pkg/tests/api/dashboards/api_dashboards_test.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/services/dashboards/service/dashboard_service.go b/pkg/services/dashboards/service/dashboard_service.go index b63b4a40f96..a9be74d79ba 100644 --- a/pkg/services/dashboards/service/dashboard_service.go +++ b/pkg/services/dashboards/service/dashboard_service.go @@ -2174,13 +2174,18 @@ func (dr *DashboardServiceImpl) unstructuredToLegacyDashboardWithUsers(item *uns dashVersion := obj.GetGeneration() spec["version"] = dashVersion + folderUID := obj.GetFolder() + if folderUID == folder.GeneralFolderUID { + folderUID = "" // empty in legacy API + } + title, _, _ := unstructured.NestedString(spec, "title") out := dashboards.Dashboard{ OrgID: orgID, ID: obj.GetDeprecatedInternalID(), // nolint:staticcheck UID: uid, Slug: slugify.Slugify(title), - FolderUID: obj.GetFolder(), + FolderUID: folderUID, Version: int(dashVersion), Data: simplejson.NewFromAny(spec), APIVersion: strings.TrimPrefix(item.GetAPIVersion(), dashboardv0.GROUP+"/"), diff --git a/pkg/tests/api/dashboards/api_dashboards_test.go b/pkg/tests/api/dashboards/api_dashboards_test.go index 50ab7d939ea..d0d8992baa4 100644 --- a/pkg/tests/api/dashboards/api_dashboards_test.go +++ b/pkg/tests/api/dashboards/api_dashboards_test.go @@ -1089,13 +1089,13 @@ func TestIntegrationDashboardServicePermissions(t *testing.T) { resp, err := postDashboard(t, grafanaListedAddr, "viewer", "viewer", dashboardPayload) require.NoError(t, err) - assert.Equal(t, http.StatusForbidden, resp.StatusCode) + require.Equal(t, http.StatusForbidden, resp.StatusCode) err = resp.Body.Close() require.NoError(t, err) resp, err = postDashboard(t, grafanaListedAddr, "editor", "editor", dashboardPayload) require.NoError(t, err) - assert.Equal(t, http.StatusOK, resp.StatusCode) + require.Equal(t, http.StatusOK, resp.StatusCode) err = resp.Body.Close() require.NoError(t, err) })