aminghadersohi commented on code in PR #44267:
URL: https://github.com/apache/superset/pull/44267#discussion_r4014767430


##########
superset/mcp_service/chart/tool/get_chart_sql.py:
##########
@@ -533,16 +544,26 @@ async def _handle_chart_sql_request(
             )
 
         # Fallback: build query context from form_data
-        try:
-            return _sql_from_form_data(
-                effective_form_data, chart, request.extra_form_data
-            )
-        except (SupersetException, CommandException, ValueError) as e:
-            await ctx.warning("Failed to build SQL from form_data: %s" % 
str(e))
-            return ChartError(
-                error="Failed to generate SQL for chart %s: %s" % (chart.id, 
e),
-                error_type="QueryGenerationFailed",
-            )
+        return await _sql_from_chart_form_data(
+            effective_form_data, chart, request.extra_form_data, ctx
+        )
+
+
+async def _sql_from_chart_form_data(
+    form_data: dict[str, Any],
+    chart: "Slice",
+    extra_form_data: dict[str, Any] | None,
+    ctx: Context,
+) -> ChartSql | ChartError:
+    """Build saved-chart fallback SQL with its existing error response 
mapping."""

Review Comment:
   `identifier` + `form_data_key` together — the saved-chart-with-unsaved-edits 
call this tool documents — clears both guards: :506 sees only the saved chart, 
and `resolve_form_data_datasource` lets form_data win. Verified: returns 
`sql="Not implemented for semantic layers"`, `error_type` null.
   
   ```suggestion
       """Build saved-chart fallback SQL with its existing error response 
mapping."""
       _, datasource_type = resolve_form_data_datasource(form_data, chart)
       if datasource_type == "semantic_view":
           return ChartError(
               error=_SEMANTIC_VIEW_SQL_UNSUPPORTED,
               error_type="Unsupported",
           )
   ```



-- 
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