Skip to content

Commit 100ad7d

Browse files
authored
fix(AlertsReports): validate anchor_list is a list (apache#38723)
1 parent c96c817 commit 100ad7d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

superset/commands/report/execute.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ def get_dashboard_urls(
268268
native_filter_params = self._report_schedule.get_native_filters_params()
269269
if anchor := dashboard_state.get("anchor"):
270270
try:
271-
anchor_list: list[str] = json.loads(anchor)
271+
anchor_list = json.loads(anchor)
272+
if not isinstance(anchor_list, list):
273+
raise json.JSONDecodeError(
274+
"Anchor value is not a list", anchor, 0
275+
)
272276
urls = self._get_tabs_urls(
273277
anchor_list,
274278
native_filter_params=native_filter_params,

tests/unit_tests/commands/report/execute_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ def test_log_data_with_missing_values(mocker: MockerFixture) -> None:
259259
["url1"],
260260
["superset/dashboard/p/url1/"],
261261
),
262+
# Test JSON scalar string anchor falls back to single tab
263+
(
264+
json.dumps("mock_tab_anchor_1"),
265+
["url1"],
266+
["superset/dashboard/p/url1/"],
267+
),
262268
],
263269
)
264270
@patch(

0 commit comments

Comments
 (0)