Skip to content

fix(folders): remove stale column/metric refs from folders on delete#38302

Merged
kgabryje merged 2 commits intoapache:masterfrom
kgabryje:fix/dataset-folders-stale-column-refs
Feb 27, 2026
Merged

fix(folders): remove stale column/metric refs from folders on delete#38302
kgabryje merged 2 commits intoapache:masterfrom
kgabryje:fix/dataset-folders-stale-column-refs

Conversation

@kgabryje
Copy link
Member

@kgabryje kgabryje commented Feb 27, 2026

SUMMARY

When a calculated column or metric is removed in the dataset editor, its UUID remains in the folder structure. The backend's validate_folders rejects the stale UUID with a 422 error, making it impossible to save the dataset.

This PR filters stale column/metric references from folders when columns or metrics change:

  • treeUtils.ts — Add filterFoldersByValidUuids() that recursively removes leaf items whose UUIDs are not in the valid set. Returns the original reference when nothing was removed (avoids unnecessary re-renders).
  • DatasourceEditor.tsx — Use filterFoldersByValidUuids in onChange() to clean the API payload before propagating to the parent. Also adds missing uuid field to the local Column interface.
  • FoldersEditor/index.tsx — Add useEffect to sync internal folder state when columns/metrics change externally, so the UI immediately reflects removed items.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

Screen.Recording.2026-02-27.at.16.37.36.mov

After:

Screen.Recording.2026-02-27.at.16.41.09.mov

TESTING INSTRUCTIONS

  1. Enable the DATASET_FOLDERS feature flag
  2. Open a dataset in the editor
  3. Go to the Calculated Columns tab and add a new calculated column
  4. Go to the Folders tab and move the column into a custom folder
  5. Save the dataset
  6. Go back to the Calculated Columns tab and delete the column
  7. Verify the Folders tab no longer shows the deleted column
  8. Save the dataset — should succeed without a 422 error

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: DATASET_FOLDERS
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

When a calculated column or metric was removed in the dataset editor,
its UUID remained in the folder structure. The backend's validate_folders
rejected the stale UUID with a 422 error, making it impossible to save.

- Add filterFoldersByValidUuids to treeUtils (reference-stable)
- Use it in DatasourceEditor.onChange to clean the API payload
- Sync FoldersEditor internal state via useEffect on columns/metrics
- Add uuid field to local Column interface

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 27, 2026

Code Review Agent Run #572d09

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: af24976..af24976
    • superset-frontend/src/components/Datasource/FoldersEditor/index.tsx
    • superset-frontend/src/components/Datasource/FoldersEditor/treeUtils.test.ts
    • superset-frontend/src/components/Datasource/FoldersEditor/treeUtils.ts
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the data:dataset Related to dataset configurations label Feb 27, 2026
@kgabryje kgabryje merged commit 5e890a8 into apache:master Feb 27, 2026
68 checks passed
@bito-code-review
Copy link
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:dataset Related to dataset configurations size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants