From 999c2c68264cf7092aa1e98eef16f0a74b90cb64 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Thu, 10 Mar 2022 12:59:29 +0200 Subject: [PATCH] fix(dashboard): import handle missing excluded charts (#19088) --- superset/dashboards/commands/importers/v1/utils.py | 2 +- tests/unit_tests/dashboards/commands/importers/v1/utils_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/superset/dashboards/commands/importers/v1/utils.py b/superset/dashboards/commands/importers/v1/utils.py index a8dbc46c0..513d1efcd 100644 --- a/superset/dashboards/commands/importers/v1/utils.py +++ b/superset/dashboards/commands/importers/v1/utils.py @@ -137,7 +137,7 @@ def update_id_refs( # pylint: disable=too-many-locals scope_excluded = native_filter.get("scope", {}).get("excluded", []) if scope_excluded: native_filter["scope"]["excluded"] = [ - id_map[old_id] for old_id in scope_excluded + id_map[old_id] for old_id in scope_excluded if old_id in id_map ] return fixed 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 320482a0e..5f3015b1b 100644 --- a/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py +++ b/tests/unit_tests/dashboards/commands/importers/v1/utils_test.py @@ -93,7 +93,7 @@ def test_update_native_filter_config_scope_excluded(app_context: None): }, }, "metadata": { - "native_filter_configuration": [{"scope": {"excluded": [101, 102]}}], + "native_filter_configuration": [{"scope": {"excluded": [101, 102, 103]}}], }, } chart_ids = {"uuid1": 1, "uuid2": 2}