Skip to content

fix(mcp): accept changed_on_delta_humanized as order_column in list tools - #42571

Open
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/fix-mcp-order-column-humanized
Open

fix(mcp): accept changed_on_delta_humanized as order_column in list tools#42571
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/fix-mcp-order-column-humanized

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

list_charts, list_datasets, and list_dashboards (MCP service tools) rejected order_column=changed_on_delta_humanized with Invalid order_column '...', even though changed_on_delta_humanized is the exact column name Superset's own REST API and list views use for "Last modified" (see order_columns in charts/api.py, datasets/api.py, dashboards/api.py). Any caller — human or LLM agent — that copies that column name to sort by "most recently modified" gets an error.

changed_on_delta_humanized is a computed/humanized rendering of changed_on (bound via Flask-AppBuilder's @renders("changed_on") in models/helpers.py), not a real queryable SQLAlchemy column, so it can't simply be passed straight through to the DAO's ORDER BY.

This PR:

  • Adds changed_on_delta_humanized to the CHART_SORTABLE_COLUMNS, DATASET_SORTABLE_COLUMNS, and DASHBOARD_SORTABLE_COLUMNS allowlists in superset/mcp_service/common/schema_discovery.py, so it's accepted and advertised as sortable (matching REST API behavior and precedent already established in daos/datasource.py's sort_col_map).
  • Resolves the alias to the real changed_on column in ModelListCore.run_tool (superset/mcp_service/mcp_core.py) before the DAO call, since BaseDAO.list() sorts via getattr(model, order_column) and would otherwise receive a Python method instead of a SQL column.
  • Leaves _validate_order_column rejecting genuinely unknown columns unchanged — only the declared alias is special-cased.
  • Updates the three tools' docstrings to document the accepted alias.

TESTING INSTRUCTIONS

  • Added unit tests in tests/unit_tests/mcp_service/system/tool/test_mcp_core.py covering the alias resolution and confirming unrelated unknown columns still raise.
  • Added regression tests in tests/unit_tests/mcp_service/chart/tool/test_list_charts.py, tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py, and tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py asserting order_column=changed_on_delta_humanized is accepted and resolves to changed_on for each of the three list tools, plus that an unknown order_column (e.g. random) still raises a ToolError.
  • Verified the new tests fail against the pre-fix code (reproducing the reported ValueError: Invalid order_column 'changed_on_delta_humanized') and pass with the fix.
  • uvx pre-commit run --files <changed files> passes (mypy, ruff, ruff-format, pylint).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@netlify

netlify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 053db4a
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7cd30bc3543e0008aed863
😎 Deploy Preview https://deploy-preview-42571--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.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.64%. Comparing base (cc35056) to head (053db4a).

Files with missing lines Patch % Lines
superset/mcp_service/mcp_core.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42571      +/-   ##
==========================================
- Coverage   66.64%   66.64%   -0.01%     
==========================================
  Files        2863     2863              
  Lines      162155   162158       +3     
  Branches    37405    37406       +1     
==========================================
- Hits       108076   108074       -2     
- Misses      52020    52024       +4     
- Partials     2059     2060       +1     
Flag Coverage Δ
hive 38.32% <33.33%> (-0.01%) ⬇️
mysql 57.87% <33.33%> (-0.01%) ⬇️
postgres 57.91% <33.33%> (-0.01%) ⬇️
presto 40.29% <33.33%> (-0.01%) ⬇️
python 59.30% <33.33%> (-0.01%) ⬇️
sqlite 57.54% <33.33%> (-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.

@aminghadersohi
aminghadersohi marked this pull request as ready for review July 29, 2026 17:27
@dosubot dosubot Bot added api Related to the REST API change:backend Requires changing the backend labels Jul 29, 2026
@github-actions github-actions Bot removed the api Related to the REST API label Jul 29, 2026

@richardfogaca richardfogaca 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.

Richard's agent here:

Blocking: could we update the existing dataset and dashboard sortable-column definition tests to include changed_on_delta_humanized and remove their assertions that the alias is absent? The constants now include it, so those two tests will fail as written. The Python unit-test job was still queued when I checked head dc2fbaf.

@bito-code-review

bito-code-review Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #91b6d4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 9 · Commit Range: 1c8a537..dc2fbaf
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/common/schema_discovery.py
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
    • tests/unit_tests/mcp_service/system/tool/test_mcp_core.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 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

@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/fix-mcp-order-column-humanized branch from dc2fbaf to e8640f0 Compare August 4, 2026 19:38
@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I don't think this is actually a blocker — I believe the two assertions you're pointing at reference a different (unrelated) pair of constants than the ones this PR changed.

There are two similarly-named-but-distinct constants in play here:

  • SORTABLE_DATASET_COLUMNS / SORTABLE_DASHBOARD_COLUMNS — local module-level constants defined near the top of list_datasets.py / list_dashboards.py. These are not used at runtime (dead/unused leftovers) and are what test_dataset_sortable_columns_definition / test_dashboard_sortable_columns_definition assert against. This PR does not touch them, so their "changed_on_delta_humanized" not in ... assertions still hold.
  • DATASET_SORTABLE_COLUMNS / DASHBOARD_SORTABLE_COLUMNS — imported from common/schema_discovery.py, actually passed to ModelListCore(sortable_columns=...) in both tool functions, and the ones this PR updates to add changed_on_delta_humanized.

Since the flagged tests check the former (unused) constants, they're unaffected by this change.

I verified this two ways on head dc2fbafe11469f4dbae870504059687a81c29f20:

  • Local pytest run: test_dataset_sortable_columns_definition PASSED, test_dashboard_sortable_columns_definition PASSED (2 passed in 1.99s).
  • CI on that same head: unit-tests (current) and unit-tests-required both passed.

So no test/code change is needed here. Separately, I agree those two dead local constants are confusing precisely because of this near-miss — I called that out as a follow-up cleanup opportunity for a future PR, but didn't want to fold an unrelated dead-code removal into this fix. Happy to split that out if useful.

@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Review Failed - Technical Failure Bito encountered technical difficulties while starting a code review session. To retry, type /review in a comment and save. If the issue persists, contact support@bito.ai.

@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/fix-mcp-order-column-humanized branch from e8640f0 to 951448b Compare August 5, 2026 00:11
@bito-code-review

bito-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8cc51c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 9 · Commit Range: 951448b..951448b
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/common/schema_discovery.py
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
    • tests/unit_tests/mcp_service/system/tool/test_mcp_core.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 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

@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/fix-mcp-order-column-humanized branch from 951448b to fcb7c72 Compare August 6, 2026 06:51
@bito-code-review

bito-code-review Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #10bac2

Actionable Suggestions - 0
Review Details
  • Files reviewed - 9 · Commit Range: fcb7c72..fcb7c72
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/common/schema_discovery.py
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
    • tests/unit_tests/mcp_service/system/tool/test_mcp_core.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 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

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Addressed the reviewer feedback in ed46db0: the dataset and dashboard tool-level sortable-column constants and their definition tests now include changed_on_delta_humanized, matching the runtime schema-discovery constants and documented behavior.\n\nValidation: targeted pre-commit hooks passed except for the pre-existing Ruff PT004 finding on allow_data_model_metadata in the dataset test file. The full --all-files run also encountered existing environment/repository issues (missing frontend glob dependency and unrelated Ruff findings). Targeted pytest could not start because superset_core is unavailable in this checkout.

@bito-code-review

bito-code-review Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #45b84c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: fcb7c72..ed46db0
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.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 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

…ools

Superset's own REST APIs and list views use `changed_on_delta_humanized`
as the "Last modified" sort key (a computed, humanized rendering of
`changed_on` bound via FAB's @renders decorator, not a real queryable
column). The MCP list_charts/list_datasets/list_dashboards tools only
allowlisted the raw `changed_on`/`created_on` columns, so requests to
sort by "most recently modified" using the REST API's own column name
were rejected with "Invalid order_column".

Add `changed_on_delta_humanized` to the sortable-column allowlists and
resolve it to `changed_on` before it reaches the DAO, mirroring how the
REST API and daos/datasource.py already treat the alias. Unknown
columns are still rejected.
@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/fix-mcp-order-column-humanized branch from ed46db0 to 053db4a Compare August 12, 2026 20:09
@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Required checks are green; the non-required experimental Playwright gate is hitting the same embedded-dashboard locator timeout seen on unrelated PRs #43088 and #43092.

@bito-code-review

bito-code-review Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #870dfd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 9 · Commit Range: 24ddc24..053db4a
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/common/schema_discovery.py
    • superset/mcp_service/dashboard/tool/list_dashboards.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
    • tests/unit_tests/mcp_service/system/tool/test_mcp_core.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 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

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

Labels

change:backend Requires changing the backend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants