Copilot commented on code in PR #40657:
URL: https://github.com/apache/superset/pull/40657#discussion_r3338101847
##########
superset/commands/report/execute.py:
##########
@@ -1031,17 +1031,45 @@ def next(self) -> None:
)
return
except Exception as ex:
- self.send_error(
- f"Error occurred for {self._report_schedule.type}:"
- f" {self._report_schedule.name}",
- str(ex),
- )
- self.update_report_schedule_and_log(
- ReportState.ERROR,
- error_message=REPORT_SCHEDULE_ERROR_NOTIFICATION_MARKER,
- )
+ # Ensure the schedule always transitions out of WORKING to
+ # ERROR, even if sending the error notification itself fails —
+ # otherwise the schedule is stuck in WORKING until the working
+ # timeout. Mirrors ReportNotTriggeredErrorState.next().
+ try:
+ self.send_error(
+ f"Error occurred for {self._report_schedule.type}:"
+ f" {self._report_schedule.name}",
+ str(ex),
+ )
+ except Exception: # noqa: BLE001 # pylint:
disable=broad-except
+ logger.warning(
+ "Failed to send error notification for report schedule
"
+ "(execution %s)",
+ self._execution_id,
+ exc_info=True,
+ )
+ finally:
+ try:
+ self.update_report_schedule_and_log(
+ ReportState.ERROR,
+
error_message=REPORT_SCHEDULE_ERROR_NOTIFICATION_MARKER,
+ )
+ except ReportScheduleUnexpectedError:
+ logger.warning(
+ "Failed to log ERROR state for report schedule "
+ "(execution %s) due to database issue",
+ self._execution_id,
+ exc_info=True,
+ )
Review Comment:
The ERROR log here always uses `REPORT_SCHEDULE_ERROR_NOTIFICATION_MARKER`,
even when `send_error()` fails. That marker is what
`find_last_error_notification()` uses to suppress retries during the grace
period, so recording it on notification failure can incorrectly prevent
subsequent error notifications (despite none being delivered). Consider only
using the marker when `send_error()` succeeds, and otherwise log the
notification failure message (mirrors the pattern in
`ReportNotTriggeredErrorState.next()`).
--
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]