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


##########
superset/mcp_service/chart/tool/generate_chart.py:
##########
@@ -886,14 +886,9 @@ async def generate_chart(  # noqa: C901
 
         logger.exception("Chart generation failed: %s", str(e))
 
-        # Extract chart_type from different sources for better error context
+        # request.config is always a validated ChartConfig (never a dict), so
+        # chart_type context isn't extractable here.
         chart_type = "unknown"
-        try:
-            if hasattr(request, "config") and isinstance(request.config, dict):
-                chart_type = request.config.chart_type
-        except (AttributeError, TypeError) as extract_error:
-            # Ignore errors when extracting chart type for error context
-            logger.debug("Could not extract chart type: %s", extract_error)
 

Review Comment:
   Fixed in 961030c: `chart_type` is now populated from the validated 
`ChartConfig` (`chart_type: str = request.config.chart_type`) instead of being 
hardcoded to "unknown", and the local variable now has an explicit type 
annotation.



##########
superset/mcp_service/chart/tool/generate_chart.py:
##########
@@ -886,14 +886,9 @@ async def generate_chart(  # noqa: C901
 
         logger.exception("Chart generation failed: %s", str(e))
 
-        # Extract chart_type from different sources for better error context
+        # request.config is always a validated ChartConfig (never a dict), so
+        # chart_type context isn't extractable here.
         chart_type = "unknown"

Review Comment:
   Fixed in 961030c: `chart_type` is now populated from the validated 
`ChartConfig` (`chart_type: str = request.config.chart_type`) instead of being 
hardcoded to "unknown", and the local variable now has an explicit type 
annotation.



##########
superset/mcp_service/chart/tool/generate_chart.py:
##########
@@ -886,14 +886,9 @@ async def generate_chart(  # noqa: C901
 
         logger.exception("Chart generation failed: %s", str(e))
 
-        # Extract chart_type from different sources for better error context
+        # request.config is always a validated ChartConfig (never a dict), so
+        # chart_type context isn't extractable here.
         chart_type = "unknown"
-        try:
-            if hasattr(request, "config") and isinstance(request.config, dict):
-                chart_type = request.config.chart_type
-        except (AttributeError, TypeError) as extract_error:
-            # Ignore errors when extracting chart type for error context
-            logger.debug("Could not extract chart type: %s", extract_error)
 
         execution_time = int((time.time() - start_time) * 1000)

Review Comment:
   Fixed in 961030c: `chart_type` is now populated from the validated 
`ChartConfig` (`chart_type: str = request.config.chart_type`) instead of being 
hardcoded to "unknown", and the local variable now has an explicit type 
annotation.



##########
superset/mcp_service/chart/tool/generate_chart.py:
##########
@@ -886,14 +886,9 @@ async def generate_chart(  # noqa: C901
 
         logger.exception("Chart generation failed: %s", str(e))
 
-        # Extract chart_type from different sources for better error context
+        # request.config is always a validated ChartConfig (never a dict), so
+        # chart_type context isn't extractable here.
         chart_type = "unknown"

Review Comment:
   Fixed in 961030c: `chart_type` is now populated from the validated 
`ChartConfig` (`chart_type: str = request.config.chart_type`) instead of being 
hardcoded to "unknown", and the local variable now has an explicit type 
annotation.



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