Skip to content

fix(mcp): fall back to title match when dashboard slug lookup misses - #39567

Merged
EnxDev merged 10 commits into
masterfrom
enxdev/fix/mcp-dashboard-empty-slug-lookup
Apr 29, 2026
Merged

fix(mcp): fall back to title match when dashboard slug lookup misses#39567
EnxDev merged 10 commits into
masterfrom
enxdev/fix/mcp-dashboard-empty-slug-lookup

Conversation

@EnxDev

@EnxDev EnxDev commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

get_dashboard_info silently returned error_type: not_found when an agent passed a slug-like identifier (e.g. "world-banks-data") for a dashboard whose slug field was empty. Many imported / example dashboards ship with empty slugs, so agents that guess the slug from the dashboard title (the natural thing to do) would hit a dead end.

After the normal id / UUID / slug lookups miss, ModelGetInfoCore now scans dashboard titles, normalizes each title and the identifier via a shared _slugify helper (lowercases, drops apostrophes, collapses non-alphanumerics to hyphens), and returns the first match.
If multiple titles slugify to the same value, it logs a warning and returns the first — collisions in real dashboards are rare and the
caller can always disambiguate by id or UUID.

The fallback column is opt-in per entity: DashboardDAO declares title_column = "dashboard_title", which ModelGetInfoCore picks up via getattr(dao_class, "title_column", None).
Other MCP tools can enable the same behavior by setting one attribute on their DAO — no core or tool changes required.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — behavior change is in the MCP service's JSON responses.

Before (master):

{
  "error": "DashboardInfo with identifier 'world-banks-data' not found",
  "error_type": "not_found"
}

After:

{
  "id": 1,
  "dashboard_title": "World Bank's Data",
  "slug": "",
   ...
}

TESTING INSTRUCTIONS

Find (or import) a dashboard whose slug field is empty but whose title slugifies to something predictable — e.g. the stock world_bank_data.py example ("World Bank's Data").

Call the MCP tool:

get_dashboard_info(request={"identifier": "world-banks-data"})

Expected: returns the dashboard (not error_type: not_found).

Sanity checks that should behave the same as before:
{"identifier": } — resolves by id.
{"identifier": ""} — resolves by UUID.
{"identifier": ""} — resolves by slug when the slug is non-empty.
{"identifier": "definitely-not-a-dashboard"} — still returns error_type: not_found (no over-matching).

Ambiguous case: create two dashboards whose titles slugify to the same value. Call get_dashboard_info with that slug. Expected: returns the first match and the server logs a warning naming all candidate ids.
Unit tests:

pytest tests/unit_tests/mcp_service/test_mcp_core.py \
tests/unit_tests/mcp_service/dashboard/
All 107 pass.

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

Many imported/example dashboards have empty slug fields, so
get_dashboard_info with an agent-guessed slug (e.g. "world-banks-data")
silently returned not_found.

ModelGetInfoCore now tries an exact case-insensitive title match,
then a slugified-title match, before giving up. When multiple titles
slugify to the same value, returns ambiguous_identifier listing the
candidate ids. The column name is sourced from DAO.title_column
(set on DashboardDAO) so other tools can opt in without touching the
core.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3ecdb0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: db8d954..db8d954
    • superset/daos/dashboard.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/test_mcp_core.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 dashboard Namespace | Anything related to the Dashboard label Apr 22, 2026
Comment thread tests/unit_tests/mcp_service/test_mcp_core.py
Comment thread tests/unit_tests/mcp_service/test_mcp_core.py
Comment thread tests/unit_tests/mcp_service/test_mcp_core.py
Comment thread tests/unit_tests/mcp_service/test_mcp_core.py
Comment thread tests/unit_tests/mcp_service/test_mcp_core.py
@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.18182% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.44%. Comparing base (6ce3885) to head (80efce9).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/mcp_core.py 16.27% 36 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39567      +/-   ##
==========================================
- Coverage   64.48%   64.44%   -0.05%     
==========================================
  Files        2566     2566              
  Lines      134046   134043       -3     
  Branches    31147    31126      -21     
==========================================
- Hits        86445    86388      -57     
- Misses      46103    46157      +54     
  Partials     1498     1498              
Flag Coverage Δ
hive 39.75% <18.18%> (-0.02%) ⬇️
mysql 60.16% <18.18%> (-0.03%) ⬇️
postgres 60.24% <18.18%> (-0.03%) ⬇️
presto 41.51% <18.18%> (-0.02%) ⬇️
python 61.80% <18.18%> (-0.03%) ⬇️
sqlite 59.87% <18.18%> (-0.03%) ⬇️
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.

@netlify

netlify Bot commented Apr 22, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 80efce9
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69f264ca9f50530008138b6d
😎 Deploy Preview https://deploy-preview-39567--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.

Comment thread superset/mcp_service/mcp_core.py Outdated
Comment thread superset/mcp_service/mcp_core.py Outdated
Comment thread superset/mcp_service/mcp_core.py Outdated
Comment thread superset/mcp_service/mcp_core.py Outdated
@EnxDev
EnxDev requested a review from msyavuz April 27, 2026 07:02
@bito-code-review

bito-code-review Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4012da

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: db8d954..84adf99
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/test_mcp_core.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

Comment thread superset/mcp_service/mcp_core.py Outdated
Comment thread superset/mcp_service/mcp_core.py Outdated
EnxDev and others added 2 commits April 27, 2026 18:50
Match the codebase convention used in superset/{cachekeys,databases,
annotation_layers,...}/api.py and drop the redundant method-level
import inside _base_filtered_query.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pre-filter via title_col.ilike("%word1%word2%...%") so the DB narrows
the candidate set; _slugify only confirms the small remainder.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EnxDev
EnxDev requested a review from msyavuz April 27, 2026 17:06
@bito-code-review

bito-code-review Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #34ae6e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 84adf99..0009083
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/test_mcp_core.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

Comment thread superset/mcp_service/mcp_core.py Outdated
Two issues in the slugified-title fallback flagged in review:

1. The ILIKE prefilter was built from the slugified identifier
   (apostrophes stripped), but compared against the raw title column —
   so "World Bank's Data" wouldn't match "%world%banks%data%" because
   "banks" is not a substring of "bank's". Apply the same apostrophe
   normalization to the title side via SQL REPLACE so the DB filter
   stays consistent with the Python `_slugify` confirmation step.

2. Without an ORDER BY, the "first match" returned on a slug collision
   is whatever the DB happens to yield first — non-deterministic across
   runs. Order the candidate query by primary key so the lowest-id
   match wins consistently, and so the warning logs the same id every
   time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EnxDev
EnxDev requested a review from msyavuz April 28, 2026 15:04
@bito-code-review

bito-code-review Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #126679

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 0009083..3e54d58
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/test_mcp_core.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

@EnxDev
EnxDev requested a review from villebro as a code owner April 29, 2026 19:47
@github-actions github-actions Bot added size/L api Related to the REST API doc Namespace | Anything related to documentation plugins dependencies:npm packages risk:ci-script PR modifies scripts that execute in CI (supply chain risk) labels Apr 29, 2026
@EnxDev
EnxDev force-pushed the enxdev/fix/mcp-dashboard-empty-slug-lookup branch from c24b86d to b540dda Compare April 29, 2026 19:52
@github-actions github-actions Bot removed api Related to the REST API doc Namespace | Anything related to documentation plugins dependencies:npm packages risk:ci-script PR modifies scripts that execute in CI (supply chain risk) labels Apr 29, 2026
@EnxDev
EnxDev merged commit e3e834b into master Apr 29, 2026
78 of 79 checks passed
@EnxDev
EnxDev deleted the enxdev/fix/mcp-dashboard-empty-slug-lookup branch April 29, 2026 21:03
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

bestlong pushed a commit to bestlong/superset that referenced this pull request May 7, 2026
…pache#39567)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
…pache#39567)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Namespace | Anything related to the Dashboard size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants