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

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 446853004a4 fix(mcp): keep a bubble chart's colors and row limit 
across updates (#44618)
446853004a4 is described below

commit 446853004a4bc8334adb246806e5354c72149b82
Author: Greg Neighbors <[email protected]>
AuthorDate: Thu Oct 1 19:51:47 2026 -0400

    fix(mcp): keep a bubble chart's colors and row limit across updates (#44618)
    
    Co-authored-by: Greg Neighbors <[email protected]>
    Co-authored-by: Claude Opus 5 <[email protected]>
---
 superset/mcp_service/chart/plugins/bubble.py       |  2 +-
 .../mcp_service/chart/test_chart_utils.py          | 55 ++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/superset/mcp_service/chart/plugins/bubble.py 
b/superset/mcp_service/chart/plugins/bubble.py
index 14dfba1cd6e..ca525284855 100644
--- a/superset/mcp_service/chart/plugins/bubble.py
+++ b/superset/mcp_service/chart/plugins/bubble.py
@@ -111,7 +111,7 @@ class BubbleChartPlugin(BaseChartPlugin):
         return "bubble_v2"
 
     def normalize_column_refs(self, config: Any, dataset_context: Any) -> Any:
-        config_dict = config.model_dump()
+        config_dict = config.model_dump(exclude_unset=True)
 
         for key in ("entity", "series"):
             col = config_dict.get(key)
diff --git a/tests/unit_tests/mcp_service/chart/test_chart_utils.py 
b/tests/unit_tests/mcp_service/chart/test_chart_utils.py
index c9321b1ae91..9c4721ffbf1 100644
--- a/tests/unit_tests/mcp_service/chart/test_chart_utils.py
+++ b/tests/unit_tests/mcp_service/chart/test_chart_utils.py
@@ -105,6 +105,61 @@ def test_merge_chart_preserves_omitted_defaults(
     assert merged["metric"] == new_form_data["metric"]
 
 
[email protected](
+    "updates,expected",
+    [
+        ({}, {"color_scheme": "lyftColors", "row_limit": 42}),
+        (
+            {"color_scheme": "googleCategory10c", "row_limit": 200},
+            {"color_scheme": "googleCategory10c", "row_limit": 200},
+        ),
+    ],
+)
+def test_merge_bubble_preserves_omitted_defaults(
+    updates: dict[str, Any], expected: dict[str, Any]
+) -> None:
+    """Normalizing a bubble config must not mark unsent fields as set.
+
+    ``merge_chart_form_data`` keeps an omitted color scheme or row limit only
+    when the field is absent from ``model_fields_set``. Dumping the config
+    without ``exclude_unset`` hands back one where every field is set, so an
+    update that mentions neither still resets both.
+    """
+    from superset.mcp_service.chart.chart_utils import map_bubble_config
+    from superset.mcp_service.chart.schemas import BubbleChartConfig
+
+    config = BubbleChartConfig(
+        chart_type="bubble_v2",
+        entity=ColumnRef(name="product"),
+        x=ColumnRef(name="revenue", aggregate="SUM"),
+        y=ColumnRef(name="revenue", aggregate="AVG"),
+        size=ColumnRef(name="revenue", aggregate="COUNT"),
+        **updates,
+    )
+    config = DatasetValidator.normalize_column_names(
+        config,
+        dataset_id=1,
+        dataset_context=DatasetContext(
+            id=1,
+            table_name="sales",
+            database_name="db",
+            available_columns=[{"name": "Product"}, {"name": "Revenue"}],
+            available_metrics=[],
+        ),
+    )
+    assert config.entity.name == "Product"
+    new_form_data = map_bubble_config(config)
+    existing = {
+        "viz_type": new_form_data["viz_type"],
+        "color_scheme": "lyftColors",
+        "row_limit": 42,
+    }
+
+    merged = merge_chart_form_data(existing, new_form_data, config)
+
+    assert {key: merged[key] for key in expected} == expected
+
+
 @pytest.mark.parametrize("dataset_rebind", [False, True])
 def test_merge_chart_defaults_on_viz_change_or_dataset_rebind(
     dataset_rebind: bool,

Reply via email to