mikebridge opened a new pull request, #44925: URL: https://github.com/apache/superset/pull/44925
### SUMMARY Restoring a chart version whose datasource (a semantic view or dataset) had since been deleted reported success and left the chart pointing at nothing. - The restore now refuses with a 422 when the snapshot's datasource no longer exists, and leaves the chart unchanged: no partial write and no new version row. - The datasource row is locked in the restore's transaction before the chart is written, so a concurrent delete cannot slip in between the check and the write. The datasource is locked before the chart, the same order a rename uses. - A soft-deleted dataset still counts as existing, since it can be restored. When a chart is restored onto one, its permission fields are now copied from that dataset; previously they kept the previous dataset's values (a stale chart permission after restore). ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A (backend). ### TESTING INSTRUCTIONS - `pytest tests/unit_tests/versioning/test_restore.py tests/unit_tests/versioning/test_restore_missing_datasource.py tests/unit_tests/versioning/test_restore_datasource_race.py` - The tests run real capture-enabled restores: the missing-datasource refusal and its 422 mapping, the soft-deleted restore with all three permission fields asserted, a two-connection test where a delete races the restore on a file-backed SQLite database, and a lock-order test. Each fails without its fix. - **Not run:** the concurrency behaviour on PostgreSQL and MySQL. SQLite serialises writers, so the row-lock path (`FOR UPDATE`) is exercised there only for statement shape. - Known limit: a chart snapshot stores the datasource type and integer ID, not a UUID, so a purged datasource whose ID has been reused by a different row still passes the existence check. ### 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]
