rusackas opened a new pull request, #38171: URL: https://github.com/apache/superset/pull/38171
### SUMMARY **Originally authored by @rdubois-kh in #26389** - This PR adopts and rebases the original contribution. This PR fixes issue #26338: `chartsInScope` references are not fixed during a Dashboard import. When a dashboard is imported using the `ImportDashboardsCommand` (v1), the chart ID references need to be updated to use the IDs of the newly created charts in the target instance. The original code was missing updates for `chartsInScope` references in several places: 1. **Native filter configuration** - `chartsInScope` in `native_filter_configuration` entries 2. **Global chart configuration** - `chartsInScope` in `global_chart_configuration` 3. **Per-chart cross-filter configuration** - `chartsInScope` in `chart_configuration[id].crossFilters` This resulted in broken filter scoping after dashboard imports, where filters would reference old chart IDs that don't exist in the target instance. **Changes made:** - Added `chartsInScope` remapping in `update_id_refs()` for native filters - Added `chartsInScope` remapping in `update_cross_filter_scoping()` for global and per-chart configurations - Refactored `update_cross_filter_scoping()` to extract helper functions `_remap_chart_ids()` and `_update_cross_filter_scope()` to reduce complexity - Added comprehensive unit tests for the new functionality Fixes #26338 ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A - Backend-only change ### TESTING INSTRUCTIONS 1. Create a dashboard with charts and configure native filters with specific charts in scope 2. Export the dashboard 3. Modify the exported ZIP to change chart UUIDs (simulating import to a different instance) 4. Import the modified dashboard 5. Verify that `chartsInScope` in the imported dashboard's `json_metadata` contains the correct new chart IDs Or run the unit tests: ```bash pytest tests/unit_tests/dashboards/commands/importers/v1/utils_test.py -v ``` ### ADDITIONAL INFORMATION - [x] Has associated issue: #26338 - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] Removes existing feature or API --- **Attribution:** This PR adopts the work from #26389 by @rdubois-kh. The original PR needed a rebase due to conflicts with recent changes to the cross-filter scoping 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]
