bito-code-review[bot] commented on code in PR #37187:
URL: https://github.com/apache/superset/pull/37187#discussion_r2696636868


##########
superset/mcp_service/chart/validation/pipeline.py:
##########
@@ -206,6 +211,41 @@ def _validate_runtime(
             # Don't fail on runtime validation errors
             return True, None
 
+    @staticmethod
+    def _normalize_column_names(request: GenerateChartRequest) -> 
GenerateChartRequest:
+        """
+        Normalize column names in the request to match canonical dataset names.
+
+        This fixes case sensitivity issues where user-provided column names
+        don't match exactly with the dataset column names. For example,
+        if a user provides 'order_date' but the dataset has 'OrderDate',
+        this method will normalize it to 'OrderDate'.
+
+        Args:
+            request: The validated chart generation request
+
+        Returns:
+            A new request with normalized column names
+        """
+        try:
+            from .dataset_validator import DatasetValidator
+
+            normalized_config = DatasetValidator.normalize_column_names(
+                request.config, request.dataset_id
+            )
+
+            # Create a new request with the normalized config
+            request_dict = request.model_dump()
+            request_dict["config"] = normalized_config.model_dump()
+
+            return GenerateChartRequest.model_validate(request_dict)
+
+        except Exception as e:

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Blind exception catch should be specific</b></div>
   <div id="fix">
   
   Replace the broad `Exception` catch at line 243 with specific exception 
types (e.g., `ImportError`, `AttributeError`, `ValueError`) to avoid masking 
unexpected errors.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
               return GenerateChartRequest.model_validate(request_dict)
    
           except (ImportError, AttributeError, KeyError, ValueError, 
TypeError) as e:
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #12ab6d</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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