bito-code-review[bot] commented on code in PR #40885:
URL: https://github.com/apache/superset/pull/40885#discussion_r3378610007
##########
superset/commands/report/execute.py:
##########
@@ -552,6 +567,19 @@ def _get_csv_data(self) -> bytes:
raise ReportScheduleCsvFailedError()
return csv_data
+ def _get_xlsx_data(self) -> bytes:
+ try:
+ xlsx_data = self._get_chart_data(ChartDataResultFormat.XLSX)
+ except SoftTimeLimitExceeded as ex:
+ raise ReportScheduleXlsxTimeout() from ex
+ except Exception as ex:
+ raise ReportScheduleXlsxFailedError(
+ f"Failed generating xlsx {str(ex)}"
+ ) from ex
+ if not xlsx_data:
+ raise ReportScheduleXlsxFailedError()
+ return xlsx_data
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing timeout diagnostic logging</b></div>
<div id="fix">
The `_get_xlsx_data` handler for `SoftTimeLimitExceeded` (line 573) lacks
the elapsed-time logging that `_get_csv_data` provides. Without this, timeouts
are harder to diagnose in production since operators won't know how long the
operation ran.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- a/superset/commands/report/execute.py
+++ b/superset/commands/report/execute.py
@@ -567,8 +567,13 @@ class BaseReportState:
def _get_xlsx_data(self) -> bytes:
try:
+ start_time = datetime.utcnow()
xlsx_data = self._get_chart_data(ChartDataResultFormat.XLSX)
except SoftTimeLimitExceeded as ex:
+ elapsed_seconds = (datetime.utcnow() -
start_time).total_seconds()
+ logger.warning(
+ "XLSX generation timeout after %.2fs - execution_id: %s",
+ elapsed_seconds,
+ self._execution_id,
+ )
raise ReportScheduleXlsxTimeout() from ex
except Exception as ex:
raise ReportScheduleXlsxFailedError(
```
</div>
</details>
</div>
<small><i>Code Review Run #077cf0</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]