rusackas commented on code in PR #40140:
URL: https://github.com/apache/superset/pull/40140#discussion_r3248422829


##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -145,6 +145,18 @@ def update_id_refs(  # pylint: disable=too-many-locals  # 
noqa: C901
                 id_map[old_id] for old_id in scope_excluded if old_id in id_map
             ]
 
+        # chartsInScope is a denormalized cache of the charts the filter
+        # currently applies to. It holds source-env chart IDs and must be
+        # remapped to destination IDs; otherwise the imported dashboard's
+        # filtersInScope / filtersOutScope computation operates on stale
+        # IDs and filters end up applied to the wrong charts (or none at
+        # all). Drop unresolvable IDs rather than passing them through.
+        charts_in_scope = native_filter.get("chartsInScope")
+        if isinstance(charts_in_scope, list):
+            native_filter["chartsInScope"] = [
+                id_map[old_id] for old_id in charts_in_scope if old_id in 
id_map
+            ]

Review Comment:
   Good call — extracted in 1b9ac54a5e. Both call sites now go through 
`_remap_charts_in_scope(container, id_map)` so the contract lives in one place 
and the two surfaces can't drift.



-- 
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]

Reply via email to