fix(reports): fail closed on alert screenshot capture instead of delivering a blank - #43031
Draft
eschutho wants to merge 1 commit into
Draft
fix(reports): fail closed on alert screenshot capture instead of delivering a blank#43031eschutho wants to merge 1 commit into
eschutho wants to merge 1 commit into
Conversation
…vering a blank Scheduled alerts that attach a dashboard/chart screenshot (PNG/PDF) could deliver a blank or partial image on large or slow-rendering dashboards, while reports were protected. Root cause: `AsyncExecuteReportScheduleCommand.run()` built a `ReportExecutionContext` only for `type == REPORT`. Alerts ran with `report_execution_context=None`, which in `take_tiled_screenshot` selects the lenient readiness predicate (`CHART_HOLDERS_READY_JS` instead of `REPORT_CHART_HOLDERS_READY_JS`) and sets `allow_partial_fallback=True`, so partial/blank tiles were combined and delivered instead of failing. Fix: route alerts that deliver a rendered screenshot (PNG/PDF with `ALERTS_ATTACH_REPORTS` enabled) through the same execution context reports use, so a blank/incomplete capture raises `ReportScheduleScreenshotFailedError` and hands off to the existing retry/notification and error handling. The `type == REPORT` discriminator is replaced with an explicit "delivers a rendered artifact" check (`_should_build_execution_context`). CSV/text alerts, alerts without the attach flag, the non-delivered query-context capture, and UI thumbnails keep their existing lenient behavior; report behavior is unchanged. Also fix a notification asymmetry: `ReportSuccessState` (Success/Grace path) logged ERROR on a send failure but did not notify the owner, unlike the first-run `ReportNotTriggeredErrorState` path. A schedule whose previous run succeeded then failed to deliver would fail silently — the common case once screenshots fail closed. The Success/Grace path now sends the owner error notification (respecting the error grace period), mirroring the first-run path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Elizabeth Thompson <eschutho@gmail.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43031 +/- ##
==========================================
- Coverage 66.59% 66.54% -0.06%
==========================================
Files 2863 2864 +1
Lines 161734 161900 +166
Branches 37262 37301 +39
==========================================
+ Hits 107712 107739 +27
- Misses 51977 52116 +139
Partials 2045 2045
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Scheduled alerts that attach a dashboard/chart screenshot (PNG/PDF) could deliver a blank or partial image on large or slow-rendering dashboards, while scheduled reports were already protected.
Root cause.
AsyncExecuteReportScheduleCommand.run()built aReportExecutionContextonly whentype == REPORT. Alerts ran withreport_execution_context=None, and insuperset/utils/screenshot_utils.pythatNone:CHART_HOLDERS_READY_JS) instead of the fail-closedREPORT_CHART_HOLDERS_READY_JS, andallow_partial_fallback=True,so partial/blank tiles were combined and delivered instead of failing.
Fix. Route alerts that deliver a rendered screenshot (PNG/PDF with
ALERTS_ATTACH_REPORTSenabled) through the same execution context reports use, so a blank/incomplete capture raisesReportScheduleScreenshotFailedErrorand hands off to the existing retry/notification and error-handling machinery. Thetype == REPORTdiscriminator is replaced with an explicit "delivers a rendered artifact" check (_should_build_execution_context).Deliberately left unchanged / lenient: CSV/text alerts, alerts without the attach flag, the non-delivered query-context capture (used to force a chart's saved query context), and UI thumbnails. Report behavior is unchanged (reports still always run under a context, regardless of format).
Secondary fix.
ReportSuccessState(the Success/Grace path) loggedERRORon a delivery failure but did not notify the owner, unlike the first-runReportNotTriggeredErrorStatepath which callssend_error(). A schedule whose previous run succeeded and then failed to deliver would fail silently — the common case once screenshots fail closed. The Success/Grace path now sends the owner error notification (respecting the error grace period), mirroring the first-run path.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable (no UI change).
TESTING INSTRUCTIONS
Automated (unit):
_should_build_execution_contextisTruefor all reports and for PNG/PDF alerts whenALERTS_ATTACH_REPORTSis enabled;Falsefor CSV/text/xlsx alerts and for alerts with the flag off — seetest_should_build_execution_context.test_success_state_send_failure_notifies_ownerandtest_success_state_send_failure_skips_notification_in_error_grace.tests/unit_tests/utils/test_screenshot_utils.py.Run:
pytest tests/unit_tests/commands/report/ \ tests/unit_tests/utils/test_screenshot_utils.py \ tests/unit_tests/utils/test_report_execution.py \ tests/unit_tests/reports/Manual: configure an alert with a PNG/PDF screenshot attachment (
ALERTS_ATTACH_REPORTSon) against a large/slow dashboard. Instead of emailing a blank image, the execution now fails closed and follows the schedule's configured retry/error-notification behavior.ADDITIONAL INFORMATION
ALERTS_ATTACH_REPORTS(governs whether alerts attach a rendered screenshot; the fail-closed path applies only when it is enabled)