fix(mcp): persist Handlebars template under camelCase key so it renders - #42725
Conversation
The MCP generate_chart/update_chart tools persisted the Handlebars template
under the snake_case form_data key `handlebars_template`, but the Handlebars
renderer reads the camelCase key `handlebarsTemplate`. Saved charts fell back
to the default `{{data}}` output, so the custom template never applied (and
with only the default template there was nothing for the CSS to style).
Persist under the camelCase key the renderer reads, mirroring how the CSS is
already stored as `styleTemplate` one line below. Covers both generate_chart
and update_chart, which both funnel through map_config_to_form_data. The
snake_case tool request-contract field (HandlebarsChartConfig.handlebars_template)
is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review Agent Run #d7d57bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #42725 +/- ##
==========================================
+ Coverage 65.46% 65.49% +0.03%
==========================================
Files 2812 2814 +2
Lines 159543 159718 +175
Branches 36412 36426 +14
==========================================
+ Hits 104441 104610 +169
- Misses 53057 53062 +5
- Partials 2045 2046 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SUMMARY
The MCP
generate_chart/update_charttools persisted the Handlebars charttemplate under the snake_case
form_datakeyhandlebars_template, but theHandlebars viz renderer reads the camelCase key
handlebarsTemplate(
plugins/plugin-chart-handlebars/src/Handlebars.tsx). As a result, a savedchart's template never matched what the renderer read, so it fell back to the
default
{{data}}output — the custom template never applied, and since onlythe default template was present, its CSS had nothing to style either.
This mirrors the fix already in place one line below for the CSS, which is
correctly stored under the camelCase
styleTemplate. The template key wassimply missed. The change persists the template under the camelCase key the
renderer reads:
snake_case request-contract field (
HandlebarsChartConfig.handlebars_template),its schema, validator, and LLM-facing examples are unchanged and remain snake_case.
generate_chartandupdate_chart— all persistencefunnels through
map_config_to_form_data.renders client-side over rows), so blast radius is limited to making the
renderer's primary read succeed. It can only fix, never regress.
Paired write-side companion to #39442, which added a snake→camel read-side
fallback in the two controls'
mapStateToProps. That fallback rescues theExplore / direct-link render but not the dashboard-tile or in-chat-preview
paths (which hydrate via
applyDefaultFormDataand never runmapStateToProps).Persisting the correct key fixes every render path for newly created/updated charts.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend
form_datakey fix; no visual change beyond the custom templatenow rendering instead of the default
{{data}}output.TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/chart/test_handlebars_chart.py(updatedtest_aggregate_mode_basicasserts the camelCase key and the absence of thesnake_case key).
generate_charttool, create a Handlebars chart witha custom template + CSS and save it. Open the saved chart in Explore, via
direct link, and on a dashboard tile — the custom template + CSS render on all
three and match the in-chat preview. Inspect the saved chart's
paramsandconfirm it contains
"handlebarsTemplate"(not"handlebars_template").ADDITIONAL INFORMATION
Related: #39442 (read-side control fallback).