Skip to content

fix(mcp): fix form_data null, dataset URL, ASCII preview, and chart rename#39109

Merged
aminghadersohi merged 4 commits intoapache:masterfrom
aminghadersohi:aminghadersohi/mcp-eval-bug-fixes
Apr 6, 2026
Merged

fix(mcp): fix form_data null, dataset URL, ASCII preview, and chart rename#39109
aminghadersohi merged 4 commits intoapache:masterfrom
aminghadersohi:aminghadersohi/mcp-eval-bug-fixes

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

Summary

Four bugs discovered during MCP eval suite testing:

1. get_chart_info returns form_data=null (sc-103137)

serialize_chart_object() never populated the form_data field from the chart's params JSON. Now parses chart.params and includes it in the response so LLMs can understand chart configuration.

2. get_dataset_info returns relative URL (sc-103138)

Dataset URLs were relative (/tablemodelview/edit/1) instead of absolute. Now uses get_superset_base_url() to construct absolute URLs, matching the pattern used by chart and dashboard serializers.

3. ASCII preview crashes with "Columns missing" (sc-103139)

When a chart's form_data has no groupby, x_axis, or all_columns fields, the ASCII preview passed an empty columns list to QueryContextFactory, causing a crash. Now returns a clear UnsupportedChart error.

4. update_chart requires config for rename (sc-103140)

UpdateChartRequest.config was required even for name-only updates. Now optional — users can rename a chart with just {identifier: 123, chart_name: "New Name"}. Extracted _find_chart() and _build_update_payload() helpers to keep complexity under C901 threshold.

Testing

  • ruff format + check clean
  • All changes in superset/mcp_service/

…ename

Four bugs discovered during eval suite run:

1. get_chart_info returns form_data=null for saved charts — now parses
   chart.params and includes form_data in the serialized response.

2. get_dataset_info returns relative URL (/tablemodelview/edit/1) — now
   uses get_superset_base_url() to construct absolute URLs, matching
   the pattern used by chart and dashboard serializers.

3. ASCII preview fails with "Columns missing in dataset" when chart has
   no groupby/x_axis columns — now returns a clear error message
   instead of crashing.

4. update_chart requires config parameter even for name-only updates —
   config is now optional, allowing chart_name to be updated alone.
   Extracted _find_chart and _build_update_payload helpers to keep
   complexity under the C901 threshold.
Copilot AI review requested due to automatic review settings April 4, 2026 16:52
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 4, 2026

Code Review Agent Run #90acf4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: eb4e7f4..eb4e7f4
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/get_chart_preview.py
    • superset/mcp_service/chart/tool/update_chart.py
    • superset/mcp_service/dataset/schemas.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the api Related to the REST API label Apr 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 4, 2026

Codecov Report

❌ Patch coverage is 10.81081% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.51%. Comparing base (d796543) to head (cde34cd).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/chart/tool/update_chart.py 13.04% 20 Missing ⚠️
superset/mcp_service/chart/schemas.py 9.09% 10 Missing ⚠️
...perset/mcp_service/chart/tool/get_chart_preview.py 0.00% 2 Missing ⚠️
superset/mcp_service/dataset/schemas.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39109      +/-   ##
==========================================
- Coverage   64.52%   64.51%   -0.01%     
==========================================
  Files        2536     2536              
  Lines      131208   131231      +23     
  Branches    30457    30463       +6     
==========================================
+ Hits        84661    84664       +3     
- Misses      45084    45104      +20     
  Partials     1463     1463              
Flag Coverage Δ
hive 40.03% <10.81%> (-0.02%) ⬇️
mysql 60.85% <10.81%> (-0.02%) ⬇️
postgres 60.93% <10.81%> (-0.02%) ⬇️
presto 40.04% <10.81%> (-0.02%) ⬇️
python 62.52% <10.81%> (-0.02%) ⬇️
sqlite 60.56% <10.81%> (-0.02%) ⬇️
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread superset/mcp_service/chart/tool/update_chart.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes several MCP eval-suite regressions in Superset’s MCP service by improving serialized metadata quality and hardening tool behavior around chart preview and chart updates.

Changes:

  • Populate ChartInfo.form_data from saved chart params JSON so get_chart_info returns usable configuration.
  • Make dataset edit URLs absolute in get_dataset_info by prefixing with get_superset_base_url().
  • Prevent ASCII preview crashes when form_data has neither columns nor metrics by returning an UnsupportedChart error.
  • Allow update_chart name-only updates by making UpdateChartRequest.config optional and extracting helper functions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
superset/mcp_service/dataset/schemas.py Builds absolute dataset edit URLs for MCP dataset info responses.
superset/mcp_service/chart/tool/update_chart.py Refactors lookup/payload building and enables rename-only updates.
superset/mcp_service/chart/tool/get_chart_preview.py Adds guardrails to avoid ASCII preview crashes on unsupported configs.
superset/mcp_service/chart/schemas.py Populates chart form_data from params and makes update config optional.
Comments suppressed due to low confidence (1)

superset/mcp_service/chart/tool/update_chart.py:176

  • This "chart not found" response sets error to a string, but GenerateChartResponse.error is ChartGenerationError | None and other error paths in this tool return a structured {error_type, message, details} object. This will either fail Pydantic validation or produce an inconsistent API shape for clients. Return a structured ChartGenerationError here too.
        if not chart:
            return GenerateChartResponse.model_validate(
                {
                    "chart": None,
                    "error": f"No chart found with identifier: {request.identifier}",
                    "success": False,
                    "schema_version": "2.0",
                    "api_version": "v1",
                }

Comment thread superset/mcp_service/chart/tool/update_chart.py
Comment on lines 1297 to +1305
class UpdateChartRequest(QueryCacheControl):
identifier: int | str = Field(..., description="Chart ID or UUID")
config: ChartConfig
config: ChartConfig | None = Field(
None,
description=(
"Chart configuration. Required for visualization changes. "
"Omit to only update the chart name."
),
)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UpdateChartRequest.config is now optional to allow name-only updates, but there are existing unit tests for update_chart and none cover the new rename-only request shape (e.g. {identifier, chart_name} without config) or the error case when both config and chart_name are omitted. Add/adjust unit tests to lock in this new behavior and prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests added in commit 05bfee1 and cde34cd:

  • TestBuildUpdatePayload.test_name_only_update — name-only rename returns dict payload
  • TestBuildUpdatePayload.test_no_config_no_name_error — neither config nor name returns ValidationError
  • TestBuildUpdatePayload.test_config_update_uses_request_chart_name — config + name uses provided name
  • TestBuildUpdatePayload.test_config_update_keeps_existing_name — config without name keeps existing
  • TestUpdateChartNameOnly.test_name_only_update_success — integration test via MCP Client
  • TestUpdateChartNameOnly.test_no_config_no_name_returns_error — integration error test

…tests

Convert all plain string error values in update_chart to proper
ChartGenerationError dicts (error_type/message/details) matching the
GenerateChartResponse schema. Add unit tests for _find_chart,
_build_update_payload helpers, and name-only update flow.
@github-actions github-actions Bot removed the api Related to the REST API label Apr 4, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 4, 2026

Code Review Agent Run #1c2396

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: eb4e7f4..cde34cd
    • superset/mcp_service/chart/tool/update_chart.py
    • tests/unit_tests/mcp_service/chart/tool/test_update_chart.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Copy Markdown
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aminghadersohi aminghadersohi merged commit 7380a59 into apache:master Apr 6, 2026
65 checks passed
michael-s-molina pushed a commit that referenced this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants