Skip to content

fix(mcp): preserve omitted chart colors and row limits - #44188

Merged
rusackas merged 3 commits into
apache:masterfrom
dennisimoo:codex/mcp-preserve-omitted-chart-defaults
Sep 22, 2026
Merged

rusackas merged 3 commits into
apache:masterfrom
dennisimoo:codex/mcp-preserve-omitted-chart-defaults

Conversation

@dennisimoo

@dennisimoo dennisimoo commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Preserve saved color_scheme and row_limit when a same-visualization, same-dataset MCP chart update omits them. Explicit values, including defaults and color_scheme=None, still override saved values.

Non-Gauge column normalizers use model_dump(exclude_unset=True), matching Gauge, so normalization preserves omission information before both update tools merge form data. This also restores the existing omitted-filter check. Chart-specific presentation defaults remain outside this bounded fix for #44176.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Backend-only. After normalization, a Pie metric update previously reset saved lyftColors / 42 to supersetColors / 100; it retains the saved values with this fix.

TESTING INSTRUCTIONS

  • The normalized-path Pie regression fails before the normalization fix and passes afterward.
  • pytest -q tests/unit_tests/mcp_service/chart/: 1,638 passed, 1 skipped.
  • Normalization tests cover all 13 chart plugins, canonical column names, omitted/empty/null filters, and unchanged input objects.
  • Pre-commit checks pass on changed files.
  • Rebased onto master to include the migration-head fix in fix(migrations): merge purge audit and username index heads #44288. Public CI still requires approval.

ADDITIONAL INFORMATION

AI-assisted with Codex; reproduced and tested locally. No independent human review is claimed.

@bito-code-review

bito-code-review Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ac7f0f

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/mcp_service/chart/chart_utils.py - 1
    • Incomplete default preservation · Line 698-700
      The comment states mappers emit defaults for omitted controls, but only `color_scheme` and `row_limit` are preserved. `map_pie_config` also emits defaults for `donut`, `show_labels`, `label_type`, `number_format`, `sort_by_metric`, etc., so a partial update (e.g. changing only `metric`) still resets those to defaults while preserving these two — inconsistent behavior for the same problem. Consider covering all mapper-emitted presentation fields or documenting the intentional subset.
Review Details
  • Files reviewed - 2 · Commit Range: dd1fc5a..dd1fc5a
    • superset/mcp_service/chart/chart_utils.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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

@codecov

codecov Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.27%. Comparing base (dd60cc2) to head (05c6a59).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44188      +/-   ##
==========================================
+ Coverage   80.25%   80.27%   +0.01%     
==========================================
  Files        2927     2927              
  Lines      173273   173276       +3     
  Branches    40173    40175       +2     
==========================================
+ Hits       139060   139094      +34     
+ Misses      31618    31578      -40     
- Partials     2595     2604       +9     
Flag Coverage Δ
hive 37.34% <0.00%> (-0.01%) ⬇️
mysql 56.95% <0.00%> (-0.01%) ⬇️
postgres 56.98% <0.00%> (-0.01%) ⬇️
presto 39.43% <0.00%> (-0.01%) ⬇️
python 84.71% <100.00%> (+0.03%) ⬆️
sqlite 56.67% <0.00%> (-0.01%) ⬇️
unit 76.22% <100.00%> (+0.03%) ⬆️

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.

@dennisimoo

dennisimoo commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Clarified the limited scope in e494e56. All 170 chart utility tests and pre-commit checks pass. The cancelled CI job had passed its tests; the new commit triggers a fresh run.

@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 05c6a59
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aa9e79cb5bd34000826e2df
😎 Deploy Preview https://deploy-preview-44188--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #96d568

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: dd1fc5a..e494e56
    • superset/mcp_service/chart/chart_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this fix @dennisimoo, and welcome! The direction is exactly right and the tests are well constructed, but I verified on this branch that the preservation never triggers on the real update_chart / update_chart_preview paths because column normalization round-trips the config and marks every field as set before the merge runs. Details and two suggested fixes in the inline comment.

Separately, the Python CI jobs on this run look unrelated to your change (none of the failures touch mcp_service, and the alembic multiple-heads error matches a master-side CI issue that was fixed later the same day), so a rebase should clear them. We will need them green before merging either way.

Comment thread superset/mcp_service/chart/chart_utils.py
@dennisimoo
dennisimoo force-pushed the codex/mcp-preserve-omitted-chart-defaults branch from e494e56 to 05c6a59 Compare September 16, 2026 00:49
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Sep 16, 2026
@bito-code-review

bito-code-review Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5f5484

Actionable Suggestions - 0
Review Details
  • Files reviewed - 15 · Commit Range: fd471bb..05c6a59
    • superset/mcp_service/chart/chart_utils.py
    • superset/mcp_service/chart/plugins/big_number.py
    • superset/mcp_service/chart/plugins/box_plot.py
    • superset/mcp_service/chart/plugins/handlebars.py
    • superset/mcp_service/chart/plugins/histogram.py
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/plugins/mixed_timeseries.py
    • superset/mcp_service/chart/plugins/pie.py
    • superset/mcp_service/chart/plugins/pivot_table.py
    • superset/mcp_service/chart/plugins/table.py
    • superset/mcp_service/chart/plugins/treemap.py
    • superset/mcp_service/chart/plugins/waterfall.py
    • superset/mcp_service/chart/plugins/xy.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
    • tests/unit_tests/mcp_service/chart/validation/test_column_name_normalization.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @dennisimoo, this addresses my change request. Verified on 05c6a59:

  • All 13 registered plugins now dump with model_dump(exclude_unset=True), so model_fields_set survives DatasetValidator.normalize_column_names. I swept every registered chart type on this head: minimal config, through normalize_column_names with a stubbed DatasetContext, mapped, then merged against a saved color_scheme="lyftColors" / row_limit=42. At my previous review SHA e494e56, 11 of the 13 lost at least one of the two saved values; on this head all 13 keep them.
  • test_merge_chart_preserves_omitted_defaults is the normalized path test I asked for, and it does fail at e494e56 (supersetColors / 100 instead of lyftColors / 42), so it pins the fix and not just the invariant.
  • tests/unit_tests/mcp_service/chart/: 1638 passed, 1 skipped locally, matching your numbers. The revived "filters" not in fields_set gate is covered by the omitted/empty/null parametrization across all 13 plugins.
  • CI is green on this head.

Leaving the remaining presentation defaults to #44176 is the right call for this PR.

LGTM.

@gabotorresruiz gabotorresruiz mentioned this pull request Sep 16, 2026
2 of 9 tasks

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Heya @dennisimoo, the exclude_unset=True fix is right, checked it against every plugin file this touches, the direct config_dict[key] indexing later in each one is always gated behind a .get(key) truthy check first, so dropping unset defaults from the dump can't introduce a KeyError. Good root cause too, gabotorresruiz's read on update_chart re-materializing all fields through the old model_dump() was exactly it.

Approving.

@rusackas
rusackas merged commit cf10e89 into apache:master Sep 22, 2026
85 checks passed
villebro pushed a commit that referenced this pull request Sep 22, 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