aminghadersohi opened a new pull request, #38402:
URL: https://github.com/apache/superset/pull/38402

   ### SUMMARY
   
   Add support for creating Handlebars template charts via the MCP service. 
Handlebars charts render query results using custom HTML templates, enabling 
fully flexible layouts like KPI cards, leaderboards, and formatted reports.
   
   Changes:
   - **`schemas.py`**: Add `HandlebarsChartConfig` Pydantic schema supporting 
both `aggregate` (metrics/groupby) and `raw` (columns) query modes, with 
validation for required fields per mode
   - **`chart_utils.py`**: Add `map_handlebars_config()` for form_data mapping, 
`_resolve_viz_type()` helper to centralize viz_type resolution from config 
objects, and update 
`generate_chart_name`/`analyze_chart_capabilities`/`analyze_chart_semantics` 
for handlebars
   - **`schema_validator.py`**: Add `_pre_validate_handlebars_config()` with 
user-friendly error messages for missing template, wrong query mode fields, and 
non-string chart_type guard
   - **`app.py`**: Update default instructions to document the new 
`chart_type="handlebars"` option
   - **Tests**: 42 unit tests covering schema validation, form_data mapping, 
chart name generation, viz_type resolution, capabilities/semantics analysis, 
and pre-validation error codes
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A - Backend-only change (MCP service schemas and utilities)
   
   ### TESTING INSTRUCTIONS
   1. Run `pytest tests/unit_tests/mcp_service/chart/test_handlebars_chart.py 
-v` to verify all 42 tests pass
   2. Run `pytest tests/unit_tests/mcp_service/ -q` to verify no regressions 
(691 tests)
   3. Verify handlebars chart creation via MCP tools with configs like:
      ```json
      {
        "dataset_id": 1,
        "config": {
          "chart_type": "handlebars",
          "handlebars_template": "<ul>{{#each data}}<li>{{this.name}}: 
{{this.value}}</li>{{/each}}</ul>",
          "metrics": [{"name": "sales", "aggregate": "SUM"}],
          "groupby": [{"name": "region"}]
        }
      }
      ```
   
   ### ADDITIONAL INFORMATION
   - [x] Introduces new feature or API
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to