You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/08/29 04:07:25 UTC

(superset) branch mcp-update-chart-preserve-form-data created (now 364f479c810)

This is an automated email from the ASF dual-hosted git repository.

aminghadersohi pushed a change to branch mcp-update-chart-preserve-form-data
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 364f479c810 fix(mcp): preserve chart form data on update

This branch includes the following new commits:

     new 364f479c810 fix(mcp): preserve chart form data on update

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix(mcp): preserve chart form data on update

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aminghadersohi pushed a commit to branch mcp-update-chart-preserve-form-data
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 364f479c810f815bac51a8bee0a33a53c880bf54
Author: Amin Ghadersohi <am...@gmail.com>
AuthorDate: Sat Aug 29 04:07:16 2026 +0000

    fix(mcp): preserve chart form data on update
---
 superset/mcp_service/chart/tool/update_chart.py    |  6 ++++-
 .../mcp_service/chart/tool/test_update_chart.py    | 31 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/superset/mcp_service/chart/tool/update_chart.py b/superset/mcp_service/chart/tool/update_chart.py
index 00c9ea8d87e..4e43ceb02d7 100644
--- a/superset/mcp_service/chart/tool/update_chart.py
+++ b/superset/mcp_service/chart/tool/update_chart.py
@@ -229,11 +229,15 @@ def _build_update_payload(
     )
 
     if parsed_config is not None:
+        existing_form_data = _get_existing_form_data(chart)
         new_form_data = map_config_to_form_data(
             parsed_config, dataset_id=effective_dataset_id
         )
         new_form_data.pop("_mcp_warnings", None)
-        merge_table_column_config(_get_existing_form_data(chart), new_form_data)
+        merge_table_column_config(existing_form_data, new_form_data)
+        new_form_data = _merge_replacement_config(
+            existing_form_data, new_form_data, parsed_config
+        )
 
         chart_name = (
             request.chart_name
diff --git a/tests/unit_tests/mcp_service/chart/tool/test_update_chart.py b/tests/unit_tests/mcp_service/chart/tool/test_update_chart.py
index 2e654fd2de1..03ad28acc0e 100644
--- a/tests/unit_tests/mcp_service/chart/tool/test_update_chart.py
+++ b/tests/unit_tests/mcp_service/chart/tool/test_update_chart.py
@@ -36,6 +36,7 @@ from superset.mcp_service.chart.schemas import (
     FilterConfig,
     GenerateChartResponse,
     LegendConfig,
+    MixedTimeseriesChartConfig,
     TableChartConfig,
     UpdateChartRequest,
     XYChartConfig,
@@ -738,6 +739,36 @@ class TestBuildUpdatePayload:
         # query_context must be cleared so get_chart_data uses updated params
         assert result["query_context"] is None
 
+    def test_config_update_preserves_unrelated_mixed_timeseries_settings(self):
+        """Save payload retains settings outside the simplified config schema."""
+        config = MixedTimeseriesChartConfig(
+            x=ColumnRef(name="ds"),
+            y=[ColumnRef(name="new_primary", aggregate="SUM")],
+            y_secondary=[ColumnRef(name="new_secondary", aggregate="SUM")],
+        )
+        request = UpdateChartRequest(identifier=1, config=config)
+        chart = Mock(
+            id=1,
+            datasource_id=7,
+            slice_name="Year-over-year metrics",
+            params=json.dumps(
+                {
+                    "viz_type": "mixed_timeseries",
+                    "time_compare": ["1 year ago"],
+                    "comparison_type_b": "percentage",
+                    "y_axis_format": ",.2f",
+                }
+            ),
+        )
+
+        result = _build_update_payload(request, chart, parsed_config=config)
+
+        assert isinstance(result, dict)
+        saved_form_data = json.loads(result["params"])
+        assert saved_form_data["time_compare"] == ["1 year ago"]
+        assert saved_form_data["comparison_type_b"] == "percentage"
+        assert saved_form_data["y_axis_format"] == ",.2f"
+
     def test_add_columns_preserves_existing_columns_and_metrics(self):
         """An additive update does not require reconstructing the table."""
         request = UpdateChartRequest(