From ece185bbdc08a596a8e8a7e146468296709751e1 Mon Sep 17 00:00:00 2001 From: Amin Ghadersohi Date: Thu, 28 May 2026 01:29:55 +0000 Subject: [PATCH] =?UTF-8?q?fix(mcp):=20address=20bito=20review=20=E2=80=94?= =?UTF-8?q?=20pre=5Fvalidate=20empty-list=20and=20chart=5Ftype=3DNone=20er?= =?UTF-8?q?ror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pivot_table.pre_validate: `not config.get("rows/metrics")` catches both missing keys and empty lists, matching PivotTableChartConfig min_length=1 - chart_utils.map_config_to_form_data: omit `(chart_type=None)` suffix from ValueError when chart_type is None to avoid misleading error messages --- superset/mcp_service/chart/chart_utils.py | 2 ++ superset/mcp_service/chart/plugins/pivot_table.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/superset/mcp_service/chart/chart_utils.py b/superset/mcp_service/chart/chart_utils.py index 04b7eae275d..b4c97b0891d 100644 --- a/superset/mcp_service/chart/chart_utils.py +++ b/superset/mcp_service/chart/chart_utils.py @@ -337,6 +337,8 @@ def map_config_to_form_data( plugin = get_registry().get(chart_type) if chart_type else None if plugin is None: + if chart_type is None: + raise ValueError(f"Unsupported config type: {type(config)}") raise ValueError( f"Unsupported config type: {type(config)} (chart_type={chart_type!r})" ) diff --git a/superset/mcp_service/chart/plugins/pivot_table.py b/superset/mcp_service/chart/plugins/pivot_table.py index 9dccc539e35..1437e0fd525 100644 --- a/superset/mcp_service/chart/plugins/pivot_table.py +++ b/superset/mcp_service/chart/plugins/pivot_table.py @@ -47,9 +47,9 @@ class PivotTableChartPlugin(BaseChartPlugin): ) -> ChartGenerationError | None: missing_fields = [] - if "rows" not in config: + if not config.get("rows"): missing_fields.append("'rows' (row grouping columns)") - if "metrics" not in config: + if not config.get("metrics"): missing_fields.append("'metrics' (aggregation metrics)") if missing_fields: