codeant-ai-for-open-source[bot] commented on code in PR #40288:
URL: https://github.com/apache/superset/pull/40288#discussion_r3272643714


##########
superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py:
##########
@@ -128,7 +128,10 @@ def open_sql_lab_with_context(
             params["sql"] = request.sql
 
         if request.title:
-            params["title"] = request.title
+            # SQL Lab's PopEditorTab reads `name` from query string to set the
+            # tab label; keep the MCP-facing field as `title` (more natural for
+            # LLMs) but emit `name` on the URL.
+            params["name"] = request.title

Review Comment:
   **Suggestion:** The new `name` query parameter is populated directly from 
`request.title` without trimming/validating whitespace-only values, so a title 
like `"   "` will now be treated as a real tab name and render as a blank label 
instead of falling back to SQL Lab's normal untitled naming. Normalize the 
value (e.g., strip and require non-empty) before adding `name` to the URL. 
[logic error]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ SQL Lab tabs opened via MCP can show blank titles.
   - โš ๏ธ LLM or client whitespace-only titles reduce tab discoverability.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. In the MCP backend, the tool entrypoint `open_sql_lab_with_context` is 
defined at
   `superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py:91-170` and 
takes an
   `OpenSqlLabRequest` (`superset/mcp_service/sql_lab/schemas.py:8-38`).
   
   2. Construct an `OpenSqlLabRequest` with a whitespace-only title, e.g. in a 
test or MCP
   client:
   
      `OpenSqlLabRequest(database_id=7, schema="analytics", sql="SELECT 1", 
title=" ")`
      (similar to how tests build the request at
      
`tests/unit_tests/mcp_service/sql_lab/tool/test_open_sql_lab_with_context.py:108-113`).
   
   3. Call `open_sql_lab_with_context(request, ctx)`; inside the function, the 
query
   parameters dict is built at `open_sql_lab_with_context.py:119-135`. Because 
`" "` is a
   non-empty string, the `if request.title:` condition at line 130 passes, and 
line 134
   executes `params["name"] = request.title`, resulting in a URL like
   `.../sqllab?dbid=7&schema=analytics&sql=...&name=+++`.
   
   4. Open the generated URL in the Superset UI; SQL Lab's `PopEditorTab` 
component
   (`superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx:60-105`) 
reads the `name`
   query parameter into the `name` variable (line 63-65) and passes it directly 
into
   `newQueryEditor = { name, dbId: Number(dbid), ... }` (lines 97-104), which 
is dispatched
   via `addQueryEditor`. The tab header component `SqlEditorTabHeader` then 
renders `qe.name`
   directly in the title span at
   `superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx:216`, 
so a name of
   `" "` renders as a visually blank tab title instead of any default "Untitled 
Query" label.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=11e0ce9ad558417b8442a5170e5c7e66&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=11e0ce9ad558417b8442a5170e5c7e66&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/sql_lab/tool/open_sql_lab_with_context.py
   **Line:** 134:134
   **Comment:**
        *Logic Error: The new `name` query parameter is populated directly from 
`request.title` without trimming/validating whitespace-only values, so a title 
like `"   "` will now be treated as a real tab name and render as a blank label 
instead of falling back to SQL Lab's normal untitled naming. Normalize the 
value (e.g., strip and require non-empty) before adding `name` to the URL.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40288&comment_hash=700a2d93fc462c55dd0944ee909c4545f3b9fad9fb1878f9c939af41799a1af7&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40288&comment_hash=700a2d93fc462c55dd0944ee909c4545f3b9fad9fb1878f9c939af41799a1af7&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to