Skip to content

Commit

Permalink
fix: enforce ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jan 30, 2025
1 parent aa67525 commit b41f330
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions superset/commands/report/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ def _get_screenshots(self) -> list[bytes]:
)
user = security_manager.find_user(username)

max_width = app.config["ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH"]

if self._report_schedule.chart:
url = self._get_url()

window_width, window_height = app.config["WEBDRIVER_WINDOW"]["slice"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
width = min(max_width, self._report_schedule.custom_width or window_width)
height = self._report_schedule.custom_height or window_height
window_size = (width, height)

screenshots: list[Union[ChartScreenshot, DashboardScreenshot]] = [
ChartScreenshot(
url,
Expand All @@ -317,11 +320,12 @@ def _get_screenshots(self) -> list[bytes]:
]
else:
urls = self.get_dashboard_urls()

window_width, window_height = app.config["WEBDRIVER_WINDOW"]["dashboard"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
width = min(max_width, self._report_schedule.custom_width or window_width)
height = self._report_schedule.custom_height or window_height
window_size = (width, height)

screenshots = [
DashboardScreenshot(
url,
Expand Down Expand Up @@ -578,9 +582,9 @@ def _send(
SupersetError(
message=ex.message,
error_type=SupersetErrorType.REPORT_NOTIFICATION_ERROR,
level=ErrorLevel.ERROR
if ex.status >= 500
else ErrorLevel.WARNING,
level=(
ErrorLevel.ERROR if ex.status >= 500 else ErrorLevel.WARNING
),
)
)
if notification_errors:
Expand Down

0 comments on commit b41f330

Please sign in to comment.