feat: Persist default folders location when repositioned in folders editor (#38105)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kamil Gabryjelski
2026-02-26 15:58:25 +01:00
committed by GitHub
parent 8c58b998b1
commit 660357c76b
7 changed files with 271 additions and 60 deletions

View File

@@ -29,7 +29,12 @@ from superset.commands.dataset.exceptions import (
DatasetNotFoundError,
MultiCatalogDisabledValidationError,
)
from superset.commands.dataset.update import UpdateDatasetCommand, validate_folders
from superset.commands.dataset.update import (
DEFAULT_COLUMNS_FOLDER_UUID,
DEFAULT_METRICS_FOLDER_UUID,
UpdateDatasetCommand,
validate_folders,
)
from superset.commands.exceptions import OwnersNotFoundValidationError
from superset.datasets.schemas import FolderSchema
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
@@ -564,6 +569,34 @@ def test_validate_folders_invalid_names(mocker: MockerFixture) -> None:
assert str(excinfo.value) == "Folder cannot have name 'Columns'"
@with_feature_flags(DATASET_FOLDERS=True)
def test_validate_folders_allows_default_folders(mocker: MockerFixture) -> None:
"""
Test that default system folders (Metrics/Columns) are allowed when using
the well-known default folder UUIDs, so their position can be persisted.
"""
folders = cast(
list[FolderSchema],
[
{
"uuid": DEFAULT_METRICS_FOLDER_UUID,
"type": "folder",
"name": "Metrics",
"children": [],
},
{
"uuid": DEFAULT_COLUMNS_FOLDER_UUID,
"type": "folder",
"name": "Columns",
"children": [],
},
],
)
# Should not raise - default folders are allowed to use reserved names
validate_folders(folders=folders, valid_uuids=set())
@with_feature_flags(DATASET_FOLDERS=True)
def test_validate_folders_invalid_uuid(mocker: MockerFixture) -> None:
"""