Skip to content

fix(mcp): use name URL param so AI-generated SQL Lab titles render#40288

Open
msyavuz wants to merge 2 commits into
masterfrom
msyavuz/feat/sqllab-mcp-tab-title
Open

fix(mcp): use name URL param so AI-generated SQL Lab titles render#40288
msyavuz wants to merge 2 commits into
masterfrom
msyavuz/feat/sqllab-mcp-tab-title

Conversation

@msyavuz
Copy link
Copy Markdown
Member

@msyavuz msyavuz commented May 20, 2026

SUMMARY

open_sql_lab_with_context was emitting ?title=… on the generated /sqllab URL, but SQL Lab's PopEditorTab only reads ?name=… (it destructures name straight into QueryEditor.name). The LLM-provided title was silently dropped, so MCP-opened tabs landed with no label at all — not even Untitled Query N.

Keep the MCP-facing field as title (natural for LLMs), but emit it on the URL as name to match the existing frontend convention. Also tightened the schema description so models actually generate a descriptive label from conversation context instead of leaving the field unset.

- params["title"] = request.title
+ params["name"] = request.title  # PopEditorTab reads ?name=

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend-only change to a URL query parameter; tab label is just the user-visible string.

TESTING INSTRUCTIONS

  1. Call the open_sql_lab_with_context MCP tool with a title (e.g. "Top customers by revenue").
  2. Open the returned URL.
  3. The SQL Lab tab should open with that title; previously it opened blank.
  4. Unit tests: pytest tests/unit_tests/mcp_service/sql_lab/tool/test_open_sql_lab_with_context.py.

ADDITIONAL INFORMATION

  • Has associated issue: No
  • Required feature flags: None
  • Changes UI: No — backend URL contract only; the tab label rendering already supports it
  • Includes DB Migration: No
  • Introduces new feature or API: No — fixes an existing one
  • Removes existing feature or API: No

`open_sql_lab_with_context` emitted `?title=...`, but SQL Lab's
`PopEditorTab` only reads `?name=...` (the QueryEditor.name field), so
the LLM-provided title was silently dropped and the tab opened with no
label. Keep the MCP-facing field as `title` (natural for LLMs) but emit
`name` on the URL, and sharpen the field description so the model
actually generates a descriptive label from conversation context.
@dosubot dosubot Bot added change:backend Requires changing the backend sqllab Namespace | Anything related to the SQL Lab labels May 20, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 20, 2026

Code Review Agent Run #494efd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: b1b21be..b1b21be
    • superset/mcp_service/sql_lab/schemas.py
    • superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py
    • tests/unit_tests/mcp_service/sql_lab/tool/test_open_sql_lab_with_context.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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit b1b21be
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a0d79127a20ec0008fe6cf1
😎 Deploy Preview https://deploy-preview-40288--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
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.14%. Comparing base (dd523c1) to head (0f30b02).
⚠️ Report is 48 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/sql_lab/schemas.py 50.00% 4 Missing ⚠️
..._service/sql_lab/tool/open_sql_lab_with_context.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40288      +/-   ##
==========================================
- Coverage   64.16%   64.14%   -0.02%     
==========================================
  Files        2591     2591              
  Lines      138163   138230      +67     
  Branches    32048    32060      +12     
==========================================
+ Hits        88650    88674      +24     
- Misses      47984    48026      +42     
- Partials     1529     1530       +1     
Flag Coverage Δ
hive 39.44% <50.00%> (-0.02%) ⬇️
mysql 59.13% <50.00%> (-0.03%) ⬇️
postgres 59.21% <50.00%> (-0.03%) ⬇️
presto 41.13% <50.00%> (-0.02%) ⬇️
python 60.64% <50.00%> (-0.03%) ⬇️
sqlite 58.85% <50.00%> (-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.

Comment thread superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py
@bito-code-review
Copy link
Copy Markdown
Contributor

The PR comment indicates a logic error where the name query parameter is being set directly from request.title without validation. This can lead to SQL Lab tabs with blank titles if the input is whitespace-only. To fix this, we should normalize the request.title value by stripping whitespace and ensuring it's non-empty before assigning it to the name parameter. This will prevent the creation of tabs with blank titles and align with SQL Lab's normal untitled naming behavior.

superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py

params["name"] = request.title.strip() if request.title else None

Per review: `if request.title:` is truthy for `"   "`, so a whitespace-only
title would have rendered as a visually blank tab label instead of falling
back to SQL Lab's default "Untitled Query N". Normalize at the schema
level (strip, coerce empty → None) matching the existing
`sql_not_empty`/`label_not_empty` validators in this file.
@pull-request-size pull-request-size Bot added size/M and removed size/S labels May 20, 2026
@msyavuz
Copy link
Copy Markdown
Member Author

msyavuz commented May 20, 2026

Bot comments should be resolved now

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/M sqllab Namespace | Anything related to the SQL Lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant