aminghadersohi opened a new pull request, #38725: URL: https://github.com/apache/superset/pull/38725
### SUMMARY When an LLM calls `generate_chart` or `generate_explore_link`, it sometimes sends Superset-native field names (`groupby`, `adhoc_filters`, `order_desc`) instead of the MCP schema field names (`group_by`, `filters`). Previously `XYChartConfig` rejected the entire request with a `ValidationError` (extra fields not permitted), causing the LLM to fall back to a minimal config with no grouping or filters. This adds a `model_validator(mode="before")` to `XYChartConfig` that intercepts the raw input dict before the `extra="forbid"` check runs: - `groupby` (list of column names) → maps first item to `group_by` as a `ColumnRef` - `adhoc_filters` → stripped silently (format is incompatible with `FilterConfig`) - `order_desc` → stripped silently (no equivalent in the MCP schema) If both `groupby` and `group_by` are provided, the explicit `group_by` takes precedence. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A — backend validation fix. ### TESTING INSTRUCTIONS Unit tests cover all scenarios in `TestXYChartConfigLegacyFields`: - `groupby` list converts to `group_by` - `adhoc_filters` stripped silently - `order_desc` stripped silently - All three legacy fields together (the original failing scenario) - `group_by` still works directly (no regression) - `groupby` does not override explicit `group_by` ```bash pytest tests/unit_tests/mcp_service/chart/test_chart_schemas.py::TestXYChartConfigLegacyFields -v ``` ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] 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]
