dosubot[bot] commented on issue #40570: URL: https://github.com/apache/superset/issues/40570#issuecomment-4588184442
<!-- Answer --> Hi @eudaimos! I'm [Dosu](https://go.dosu.dev/dosubot) and I'm helping the Apache Superset team. This is a legitimate gap in the MCP code path. I dug into the implementation and can confirm the root cause: In the normal chart flow, `get_sqla_query()` explicitly merges the dataset's saved template parameters before creating the template processor [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L1494-L1501): ```python template_kwargs.update(self.template_params_dict) template_processor = self.get_template_processor(**template_kwargs) ``` The MCP `generate_chart` tool skips this entirely — it goes directly to `QueryContextFactory.create()` with the datasource and form_data but **never loads or merges `dataset.template_params_dict`** into the template context . The result is that Jinja literals are sent to the engine unrendered. Similarly, `execute_sql` will render Jinja only when `template_params` is explicitly passed in the request [[2]](https://github.com/apache/superset/pull/39858) — it doesn't consult the dataset's saved `template_params` on its own. This follows a pattern seen before — PR #39207 fixed a nearly identical issue where `template_processor` wasn't being passed through for cross-filter queries on virtual datasets [[3]](https://github.com/apache/superset/pull/39207), and PR #34802 fixed user-provided template parameters not being threaded through the SQL processing pipeline [[4]](https://github.com/apache/superset/pull/34802). **The fix** would be to have MCP tools (particularly `generate_chart` and the chart preview path) look up `dataset.template_params_dict` and merge it into the template context before creating the query context — mirroring what `get_sqla_query()` does at lines 1494-1501. User-provided params from the MCP request could override dataset defaults with a simple merge order. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=9bebeb1e-489a-4421-a18d-fa4c16ae9eba) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) -- 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]
