mikebridge opened a new pull request, #44926: URL: https://github.com/apache/superset/pull/44926
### SUMMARY A chart whose dataset was hard-deleted kept its denormalized permission fields, so it stayed in chart lists for holders of the old schema or catalog grant even though the chart itself could not be opened. If a new dataset later reused the old ID, the chart could attach itself to it. - **On save:** a chart whose datasource no longer exists has its permission fields cleared. A soft-deleted dataset still resolves, so trash and restore keep chart access. - **On purge:** when the retention purge (or a force purge) hard-deletes a dataset, it now keeps that dataset's charts but sets their `datasource_id` and permission fields to NULL in the same transaction, as an ordinary hard delete already does. The statement is one UPDATE filtered by datasource type and ID; it adds no deletes, a dry run does not execute it, and a failure rolls back with the rest of that object's purge. - `UPDATING.md` describes the change, including that charts orphaned by purges that ran before it are not migrated. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A (backend). ### TESTING INSTRUCTIONS - `pytest tests/unit_tests/commands/deletion_retention/test_purge_chart_detach.py tests/unit_tests/commands/deletion_retention/test_purge_policy.py tests/unit_tests/models/slice_test.py tests/unit_tests/charts/semantic_view_chart_filter_test.py` - The purge tests go through the real `cascade_hard_delete`: the orphan chart is detached, a chart on a semantic view with the same numeric ID is untouched, a later dataset reusing the ID cannot take the chart over, a failure rolls back, and a dry run changes nothing. - **Not run locally:** the integration lane. The edited integration tests assert the new contract (chart kept, four fields cleared) but have only been run by CI; the UPDATE is compiled for PostgreSQL, MySQL and SQLite in a unit test, not executed on the first two. Behaviour changes to weigh: - Orphaned charts disappear from chart lists for users whose only access was the old schema or catalog grant. Admins and chart owners still see them. - The purge's UPDATE is a maintenance write and does not create a chart version row. - One follow-up from review, not done here: the `UPDATING.md` audit advice tells operators to look for charts whose dataset no longer exists, which cannot find an orphan whose old ID has already been reused. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Introduces new feature or API - [ ] Removes existing feature or API 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
