Skip to content

fix(mcp): add AliasChoices to chart/dashboard/dataset request schemas#41597

Draft
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-alias-choices-schemas
Draft

fix(mcp): add AliasChoices to chart/dashboard/dataset request schemas#41597
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-alias-choices-schemas

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

Summary

  • LLM-driven MCP callers commonly send field name variants like id instead of identifier, or columns instead of select_columns. Pydantic silently drops unrecognized keys and falls back to field defaults, so these requests behaved as if the field was never sent at all.
  • Adds validation_alias=AliasChoices(...) plus model_config = ConfigDict(populate_by_name=True) to the chart, dashboard, and dataset MCP request schemas that were missing them, following the existing pattern already used by OpenSqlLabRequest and GenerateDashboardRequest.
  • Affected schemas: GetChartInfoRequest, ListChartsRequest, GenerateExploreLinkRequest, UpdateChartRequest, UpdateChartPreviewRequest, GetChartDataRequest, GetChartPreviewRequest, GetChartSqlRequest, ListDashboardsRequest, GetDashboardInfoRequest, AddChartToDashboardRequest, ListDatasetsRequest, GetDatasetInfoRequest.

Test plan

  • ruff format / ruff check clean on all changed files
  • mypy and pylint pre-commit hooks pass on all changed files
  • Added unit tests covering each new alias (id/chart_id/dashboard_id/dataset_ididentifier, columnsselect_columns, dashboard/chartdashboard_id/chart_id) in test_chart_schemas.py, test_dashboard_schemas.py, and a new test_dataset_schemas.py
  • CI test suite (could not run the full pytest suite locally — mysqlclient failed to build in this sandbox due to missing native libs)

LLM callers commonly send 'id' instead of 'identifier', 'columns'
instead of 'select_columns', etc. Pydantic silently drops unrecognized
field names and falls back to defaults, causing requests to behave as
if the field was never sent. Add validation_alias=AliasChoices(...) and
populate_by_name=True to the chart, dashboard, and dataset MCP request
schemas that were still using the bare field name, matching the pattern
already used by OpenSqlLabRequest and GenerateDashboardRequest.
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.42%. Comparing base (fd9c84b) to head (990c4c7).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41597      +/-   ##
==========================================
- Coverage   64.42%   64.42%   -0.01%     
==========================================
  Files        2668     2668              
  Lines      147182   147194      +12     
  Branches    33947    33947              
==========================================
+ Hits        94821    94828       +7     
- Misses      50646    50649       +3     
- Partials     1715     1717       +2     
Flag Coverage Δ
hive 39.11% <100.00%> (+0.01%) ⬆️
mysql 57.66% <100.00%> (+<0.01%) ⬆️
postgres 57.72% <100.00%> (+<0.01%) ⬆️
presto 40.66% <100.00%> (+0.01%) ⬆️
python 59.13% <100.00%> (+<0.01%) ⬆️
sqlite 57.36% <100.00%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants