dosubot[bot] commented on issue #40732: URL: https://github.com/apache/superset/issues/40732#issuecomment-4616812272
<!-- Answer --> @eudaimos — I dug into this and can confirm the root cause. It's a field-aliasing gap between how form_data is stored and how query_context is constructed. **Root Cause:** The MCP `generate_chart` tool correctly sets `form_data` with `query_mode: "raw"` and `all_columns: [...]` . However, the backend's query context construction path does **not** transform `all_columns` → `columns` the way the frontend does. Here's the disconnect: 1. The **frontend** `extractQueryFields` maps `all_columns` → `columns` before building the query object [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-core/src/query/extractQueryFields.ts#L45-L57) 2. The **backend** `QueryObject._rename_deprecated_fields()` only maps `groupby` → `columns` — it does **not** include `all_columns` → `columns` [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/common/query_object.py#L217-L235) 3. The `ChartDataQueryObjectSchema` uses `unknown = EXCLUDE` [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py#L1134-L1136), which **silently drops** `all_columns` during deserialization So when the MCP service constructs the query context with `all_columns` in the payload, it gets stripped during schema deserialization, leaving `columns`, `metrics`, and `groupby` all empty — triggering the validation at `get_sqla_query()` [[4]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L1527-L1528): ```python if not metrics and not columns and not groupby: raise QueryObjectValidationError(_("Empty query?")) ``` **The fix** should happen in the MCP service's query context construction: when `query_mode == "raw"` and `all_columns` is populated, it needs to map `all_columns` → `columns` in the query object (not just in form_data) before passing it to the chart data API — mirroring what the frontend's `extractQueryFields` does. Alternatively, the backend could add `all_columns` to the deprecated field mappings, though that's more invasive. This is essentially the same architectural pattern that caused the Jinja issue in #40570 — the MCP code path bypasses transformations that the Explore UI's frontend handles transparently. <!-- 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).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-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=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=48d23fd6-e466-4425-82f8-66e109d46c95) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-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=static-docs-share-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]
