fix(AlertsReports): validate anchor_list is a list (#38723)

This commit is contained in:
Mehmet Salih Yavuz
2026-03-23 18:19:57 +03:00
committed by GitHub
parent c96c817ef5
commit 100ad7d9ee
2 changed files with 11 additions and 1 deletions

View File

@@ -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,

View File

@@ -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(