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

(superset) branch master updated: fix(mcp): persist Handlebars template under camelCase key so it renders (#42725)

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

rebenitez1802 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 1478e32bc26 fix(mcp): persist Handlebars template under camelCase key so it renders (#42725)
1478e32bc26 is described below

commit 1478e32bc26fdd91c984062f64f421161e898049
Author: Rafael Benitez <re...@gmail.com>
AuthorDate: Tue Aug 4 16:21:57 2026 -0400

    fix(mcp): persist Handlebars template under camelCase key so it renders (#42725)
    
    Co-authored-by: Claude Opus 4.8 (1M context) <no...@anthropic.com>
---
 superset/mcp_service/chart/chart_utils.py                   | 5 ++++-
 tests/unit_tests/mcp_service/chart/test_handlebars_chart.py | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/superset/mcp_service/chart/chart_utils.py b/superset/mcp_service/chart/chart_utils.py
index 92110d217bc..13bf0a3c58c 100644
--- a/superset/mcp_service/chart/chart_utils.py
+++ b/superset/mcp_service/chart/chart_utils.py
@@ -1112,7 +1112,10 @@ def map_handlebars_config(config: HandlebarsChartConfig) -> Dict[str, Any]:
     """Map handlebars chart config to Superset form_data."""
     form_data: Dict[str, Any] = {
         "viz_type": "handlebars",
-        "handlebars_template": config.handlebars_template,
+        # Persist under the camelCase key the Handlebars renderer reads
+        # (`formData.handlebarsTemplate`); the snake_case `handlebars_template`
+        # is the tool's request-contract field, not the persisted form_data key.
+        "handlebarsTemplate": config.handlebars_template,
         "row_limit": config.row_limit,
         "order_desc": config.order_desc,
     }
diff --git a/tests/unit_tests/mcp_service/chart/test_handlebars_chart.py b/tests/unit_tests/mcp_service/chart/test_handlebars_chart.py
index 377a9cb9006..3ac3061abbb 100644
--- a/tests/unit_tests/mcp_service/chart/test_handlebars_chart.py
+++ b/tests/unit_tests/mcp_service/chart/test_handlebars_chart.py
@@ -183,7 +183,9 @@ class TestMapHandlebarsConfig:
         result = map_handlebars_config(config)
 
         assert result["viz_type"] == "handlebars"
-        assert result["handlebars_template"] == "<p>{{data}}</p>"
+        # Persisted under the camelCase key the renderer reads, not snake_case.
+        assert result["handlebarsTemplate"] == "<p>{{data}}</p>"
+        assert "handlebars_template" not in result
         assert result["query_mode"] == "aggregate"
         assert result["row_limit"] == 1000
         assert result["order_desc"] is True