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

   <!-- Bito Reply -->
   The flagged issue is correct. Catching a generic `Exception` around 
`database.get_df` is indeed too broad, as it swallows programming errors (like 
`RuntimeError` or `ValueError`) that should be surfaced as errors rather than 
suppressed as warnings. To resolve this, you should catch only the specific 
exceptions expected from database connectivity or query execution (e.g., 
`SupersetException`, `DatabaseError`, or specific driver exceptions), allowing 
unexpected errors to propagate to the outer handler.
   
   Here is the corrected implementation for 
`superset/datasets/datetime_format_detector.py`:
   
   ```python
               try:
                   df = database.get_df(sql, dataset.schema)
               except (SupersetException, Exception) as ex:  # Replace 
Exception with specific database exceptions
                   logger.warning(
                       "Could not query column %s.%s for format detection: %s",
                       dataset.table_name,
                       column.column_name,
                       str(ex),
                   )
                   return None
   ```
   
   (Note: Please replace `SupersetException` with the actual base exception 
class used by your database adapter for query failures.)
   
   **superset/datasets/datetime_format_detector.py**
   ```
   try:
                   df = database.get_df(sql, dataset.schema)
               except (SupersetException, Exception) as ex:  # Replace 
Exception with specific database exceptions
                   logger.warning(
                       "Could not query column %s.%s for format detection: %s",
                       dataset.table_name,
                       column.column_name,
                       str(ex),
                   )
                   return None
   ```


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