You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/08/21 18:12:20 UTC

(superset) branch get-image-always-return created (now 02f0df4e54)

This is an automated email from the ASF dual-hosted git repository.

beto pushed a change to branch get-image-always-return
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 02f0df4e54 fix: make get_image() always return

This branch includes the following new commits:

     new 02f0df4e54 fix: make get_image() always return

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix: make get_image() always return

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch get-image-always-return
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 02f0df4e544e7327a9f478a89b34c3d502702796
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Aug 21 14:12:06 2025 -0400

    fix: make get_image() always return
---
 superset/dashboards/api.py    |  2 --
 superset/utils/screenshots.py | 10 +++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index 54e05df8b7..43bbfc1ec5 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -1200,8 +1200,6 @@ class DashboardRestApi(BaseSupersetModelRestApi):
 
         if cache_payload := DashboardScreenshot.get_from_cache_key(digest):
             image = cache_payload.get_image()
-            if not image:
-                return self.response_404()
             if download_format == "pdf":
                 pdf_img = image.getvalue()
                 # Convert the screenshot to PDF
diff --git a/superset/utils/screenshots.py b/superset/utils/screenshots.py
index 23493471b8..250cd89a6d 100644
--- a/superset/utils/screenshots.py
+++ b/superset/utils/screenshots.py
@@ -23,7 +23,7 @@ from enum import Enum
 from io import BytesIO
 from typing import cast, TYPE_CHECKING, TypedDict
 
-from flask import current_app as app
+from flask import abort, current_app as app
 
 from superset import feature_flag_manager, thumbnail_cache
 from superset.extensions import event_logger
@@ -121,10 +121,10 @@ class ScreenshotCachePayload:
         self.update_timestamp()
         self.status = StatusValues.ERROR
 
-    def get_image(self) -> BytesIO | None:
-        if not self._image:
-            return None
-        return BytesIO(self._image)
+    def get_image(self) -> BytesIO:
+        if self._image is None:
+            abort(404)
+        return BytesIO(cast(bytes, self._image))
 
     def get_timestamp(self) -> str:
         return self._timestamp