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

   ### SUMMARY
   
   The chart data API makes its query request available through Flask's global 
form-data fallback because Jinja macros such as `filter_values`, `get_filters`, 
and `url_param` read query inputs from that context. Programmatically 
constructed MCP queries skipped that step, so virtual datasets and metrics 
using those macros could fail despite the equivalent API query succeeding.
   
   This extracts the API's form-data assignment into a shared helper and uses 
it for `get_chart_data` and `query_dataset`. MCP query contexts are represented 
in the same datasource/queries/form-data shape consumed by the existing Jinja 
lookup path; no synthetic request context or duplicated macro-specific behavior 
is introduced.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable; this is a backend-only query execution fix.
   
   ### TESTING INSTRUCTIONS
   
   - `pytest -q tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py 
tests/unit_tests/mcp_service/dataset/tool/test_query_dataset.py` (136 passed)
   - `pytest -q tests/unit_tests/mcp_service` (3318 passed; one unrelated 
existing health-check smoke failure because the test environment has no version 
string configured)
   - `uvx pre-commit run --files superset/charts/data/api.py 
superset/charts/data/form_data.py 
superset/mcp_service/chart/tool/get_chart_data.py 
superset/mcp_service/dataset/tool/query_dataset.py 
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py 
tests/unit_tests/mcp_service/dataset/tool/test_query_dataset.py`
   - `pre-commit run --all-files` (Python checks passed; frontend-only hooks 
could not complete because frontend dependencies such as `glob` and 
`postcss-styled-syntax` are not installed; the formatter also reported 
pre-existing frontend formatting drift)
   
   The regression tests execute `filter_values` and `get_filters` during an MCP 
`query_dataset` call and cover `url_param` plus implicit dataset lookup for 
`metric()` using chart-shaped query context.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ## Blast radius
   
   This affects only MCP chart and dataset query execution plus the existing 
chart-data API context assignment. It does not change authorization, RLS, 
workspace isolation, schemas, migrations, feature flags, or non-MCP query 
behavior.
   
   ## Risk & rollback
   
   Risk is limited to the Flask-global form-data payload used while compiling 
MCP queries. The payload is built from the already validated query context and 
matches the existing API representation. Rollback is a revert of this commit.
   
   ## Review guidance
   
   Start with `superset/charts/data/form_data.py`, then verify the two MCP call 
sites populate it immediately before `ChartDataCommand` execution. The tests 
document the request-dependent macro boundary.
   
   ## Eval evidence
   
   No model or prompt evaluation was run because this change does not modify 
tool schemas, descriptions, prompts, model routing, or generated responses. The 
deterministic MCP regression coverage passes 136/136; the full MCP unit suite 
passes 3318/3319 with the environment-only health-check failure described above.
   
   ## Cost & latency delta
   
   No model parameters, prompts, or tool payload schemas changed, so token and 
model-cost delta is zero. The added work serializes the already-built query 
objects once per affected call; no external request or database query is added.
   
   ## Prompt / non-determinism
   
   No prompt, model routing, or non-deterministic behavior changed.
   


-- 
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