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


##########
superset/mcp_service/chart/validation/dataset_validator.py:
##########
@@ -112,6 +106,32 @@ def validate_against_dataset(
 
         return True, None
 
+    @staticmethod
+    def _validate_columns_exist(
+        column_refs: List[ColumnRef], dataset_context: DatasetContext
+    ) -> ChartGenerationError | None:
+        """Validate that non-saved-metric column refs exist in the dataset."""
+        invalid_columns = []
+        for col_ref in column_refs:
+            if col_ref.saved_metric:
+                continue
+            if not DatasetValidator._column_exists(col_ref.name, 
dataset_context):
+                invalid_columns.append(col_ref)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Validation Logic Bug</b></div>
   <div id="fix">
   
   The new _validate_columns_exist method still uses _column_exists, which 
checks both dataset columns and metrics. For ColumnRefs with 
saved_metric=False, it should only validate against available_columns to 
prevent metric names from incorrectly passing as valid columns.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
               column_names = {col["name"].lower() for col in 
dataset_context.available_columns}
               if col_ref.name.lower() not in column_names:
                   invalid_columns.append(col_ref)
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #fe881b</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