diff --git a/superset/dashboards/commands/importers/v1/utils.py b/superset/dashboards/commands/importers/v1/utils.py index 0067c2c52..c3dee1578 100644 --- a/superset/dashboards/commands/importers/v1/utils.py +++ b/superset/dashboards/commands/importers/v1/utils.py @@ -84,6 +84,7 @@ def update_id_refs( # pylint: disable=too-many-locals metadata["filter_scopes"] = { str(id_map[int(old_id)]): columns for old_id, columns in metadata["filter_scopes"].items() + if int(old_id) in id_map } # now update columns to use new IDs: @@ -107,6 +108,7 @@ def update_id_refs( # pylint: disable=too-many-locals { str(id_map[int(old_id)]): value for old_id, value in default_filters.items() + if int(old_id) in id_map } ) diff --git a/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py b/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py index 7ff829437..d0ee3157f 100644 --- a/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py +++ b/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py @@ -45,7 +45,10 @@ def test_update_id_refs_immune_missing( # pylint: disable=invalid-name }, }, "metadata": { - "filter_scopes": {"101": {"filter_name": {"immune": [102, 103],},},}, + "filter_scopes": { + "101": {"filter_name": {"immune": [102, 103]}}, + "104": {"filter_name": {"immune": [102, 103]}}, + }, }, "native_filter_configuration": [], }