bito-code-review[bot] commented on PR #42474:
URL: https://github.com/apache/superset/pull/42474#issuecomment-5090659842

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of 
`_get_query_context_column_names` iterates over the `columns` list and passes 
each item directly to `utils.get_column_name` without validating the item's 
structure, which can cause an unhandled exception if an item is malformed 
(e.g., `None` or an invalid dictionary). 
   
   To resolve this, you should add a validation step inside the generator 
expression to ensure each `column_` is a valid type (e.g., a dictionary) before 
processing it. Here is the corrected implementation for the loop in 
`superset/connectors/sqla/models.py`:
   
   ```python
       for query in queries:
           if not isinstance(query, dict):
               continue
           columns = query.get("columns") or query.get("groupby")
           if not isinstance(columns, list):
               continue
           for column_ in columns:
               if isinstance(column_, (dict, str)):
                   column_names.add(utils.get_column_name(column_))
   
       return column_names
   ```
   
   There are no other comments in this PR. Would you like me to proceed with 
any other changes?
   
   **superset/connectors/sqla/models.py**
   ```
   for query in queries:
           if not isinstance(query, dict):
               continue
           columns = query.get("columns") or query.get("groupby")
           if not isinstance(columns, list):
               continue
           for column_ in columns:
               if isinstance(column_, (dict, str)):
                   column_names.add(utils.get_column_name(column_))
   
       return column_names
   ```


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