diff --git a/superset/commands/report/execute.py b/superset/commands/report/execute.py index 11593649815..90f574e27cb 100644 --- a/superset/commands/report/execute.py +++ b/superset/commands/report/execute.py @@ -268,7 +268,11 @@ class BaseReportState: native_filter_params = self._report_schedule.get_native_filters_params() if anchor := dashboard_state.get("anchor"): try: - anchor_list: list[str] = json.loads(anchor) + anchor_list = json.loads(anchor) + if not isinstance(anchor_list, list): + raise json.JSONDecodeError( + "Anchor value is not a list", anchor, 0 + ) urls = self._get_tabs_urls( anchor_list, native_filter_params=native_filter_params, diff --git a/tests/unit_tests/commands/report/execute_test.py b/tests/unit_tests/commands/report/execute_test.py index b2481be1bb3..e40a45d9bbe 100644 --- a/tests/unit_tests/commands/report/execute_test.py +++ b/tests/unit_tests/commands/report/execute_test.py @@ -259,6 +259,12 @@ def test_log_data_with_missing_values(mocker: MockerFixture) -> None: ["url1"], ["superset/dashboard/p/url1/"], ), + # Test JSON scalar string anchor falls back to single tab + ( + json.dumps("mock_tab_anchor_1"), + ["url1"], + ["superset/dashboard/p/url1/"], + ), ], ) @patch(