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


##########
superset/commands/report/execute.py:
##########
@@ -541,24 +568,24 @@ def _get_csv_data(self) -> bytes:
         except SoftTimeLimitExceeded as ex:
             elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
             logger.warning(
-                "CSV generation timeout after %.2fs - execution_id: %s",
+                "%s generation timeout after %.2fs - execution_id: %s",
+                label,
                 elapsed_seconds,
                 self._execution_id,
             )
-            raise ReportScheduleCsvTimeout() from ex
+            raise timeout_error() from ex
         except Exception as ex:
             elapsed_seconds = (datetime.utcnow() - start_time).total_seconds()
             logger.exception(
-                "CSV generation failed after %.2fs - execution_id: %s",
+                "%s generation failed after %.2fs - execution_id: %s",
+                label,
                 elapsed_seconds,
                 self._execution_id,
             )
-            raise ReportScheduleCsvFailedError(
-                f"Failed generating csv {str(ex)}"
-            ) from ex
-        if not csv_data:
-            raise ReportScheduleCsvFailedError()
-        return csv_data
+            raise failed_error(f"Failed generating {label.lower()} {str(ex)}") 
from ex
+        if not data:
+            raise failed_error()
+        return data

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing XLSX timeout test coverage</b></div>
   <div id="fix">
   
   The `_get_data` method now dispatches XLSX-specific exceptions (lines 
527–532, 571–576, 585), but no test exercises the `SoftTimeLimitExceeded` → 
`ReportScheduleXlsxTimeout` path for XLSX format. The existing tests only cover 
the CSV timeout variant (`test_get_notification_content_csv_format` at test 
line ~1300). Without this test, an incorrect exception mapping for XLSX would 
go undetected.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #daaf18</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



##########
tests/unit_tests/commands/report/execute_test.py:
##########
@@ -1190,6 +1191,22 @@ def 
test_update_query_context_wraps_screenshot_failure(mocker: MockerFixture) ->
         state._update_query_context()
 
 
+def test_update_query_context_wraps_screenshot_failure_xlsx(
+    mocker: MockerFixture,
+) -> None:
+    """_update_query_context surfaces the caller's error class (XLSX, not 
CSV)."""
+    schedule = mocker.Mock(spec=ReportSchedule)
+    state = BaseReportState(schedule, datetime.utcnow(), uuid4())

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Deprecated datetime.utcnow usage</b></div>
   <div id="fix">
   
   `datetime.utcnow()` is deprecated in Python 3.12+ and returns a naive 
datetime. Replace with `datetime.now(timezone.utc)` from `datetime` module.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #daaf18</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