hughhhh commented on code in PR #42284:
URL: https://github.com/apache/superset/pull/42284#discussion_r3632236484
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -96,6 +103,59 @@ def _chart_label(chart: Any) -> str:
return f"{chart.id} - {chart.slice_name or ''}".strip()
+def _has_empty_query_context(raw: Any) -> bool:
+ """
+ Whether a chart has no usable saved query context to export data from.
+
+ Covers a missing/blank value, a string that does not parse as JSON, a value
+ that parses to something other than an object (e.g. ``"null"``), and an
+ object with no queries (e.g. ``"{}"`` or ``{"queries": []}``). All of these
+ are treated the same as a missing context: the chart is skipped and listed
+ under the "no query context" remediation rather than raising mid-export.
+ """
+ if not raw:
+ return True
+ try:
+ parsed = json.loads(raw)
+ except (TypeError, ValueError):
+ return True
+ return not isinstance(parsed, dict) or not parsed.get("queries")
+
+
+def _rebuild_viz_types() -> set[str]:
+ """Viz types eligible for form-data query-context rebuild (config or
default)."""
+ return current_app.config.get("EXCEL_EXPORT_REBUILD_VIZ_TYPES") or
REBUILD_VIZ_TYPES
Review Comment:
Fixed in de7dfc1585: `_rebuild_viz_types` now checks `is None` explicitly
instead of `or`, so an operator can disable the rebuild with an explicit empty
set instead of it silently falling back to the default allowlist. Added a
parametrized unit test (None → default, empty set → disabled, override →
honored).
--
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]