codeant-ai-for-open-source[bot] commented on code in PR #44577:
URL: https://github.com/apache/superset/pull/44577#discussion_r4132195914
##########
superset/dashboards/filter_scope.py:
##########
@@ -57,8 +60,15 @@
def build_chart_layout_items(position_data: dict[str, Any]) ->
ChartLayoutItems:
- """Map each chart id in the layout to the layout items that render it."""
+ """Map each chart id in the layout to the layout items that render it.
+
+ A layout that is not a mapping (``position_json`` holding a JSON string or
+ array) places no charts, so every derived scope comes out empty.
+ """
chart_layout_items: ChartLayoutItems = {}
+ if not isinstance(position_data, dict):
+ logger.warning("Dashboard layout is not a mapping; no charts are in
scope")
+ return chart_layout_items
Review Comment:
Yes. When `position_data` is non-mapping, `chart_layout_items` is
intentionally empty, so every layout-derived scope—including
`selectedLayers`—should be empty. Otherwise the API can still report chart IDs
despite there being no parseable layout containing those charts.
Update the `selectedLayers` branch in `get_chart_ids_in_scope` to require
layout membership, for example:
```python
chart_ids = {
chart_id
for chart_id in chart_ids
if chart_id in chart_layout_items
}
```
or apply that condition while resolving each selected-layer key. This
preserves the existing behavior for valid layouts while ensuring malformed
layouts consistently produce empty `chartsInScope` and `tabsInScope`. Add a
regression test with `selectedLayers` and a non-mapping layout to prevent the
mismatch from returning.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]