This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 5.0 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2c03455f61333e734b68e61372b0579d7eadd92b Author: Kamil Gabryjelski <[email protected]> AuthorDate: Thu Feb 20 19:59:39 2025 +0100 fix: Download as PDF fails due to cache error (#32332) (cherry picked from commit 42a3c523ae76b6ba82fad71b600015145ede20f7) --- superset/dashboards/api.py | 1 + superset/utils/screenshots.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index c15610010b..2eca96dfeb 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -1127,6 +1127,7 @@ class DashboardRestApi(BaseSupersetModelRestApi): dashboard_url=dashboard_url, thumb_size=thumb_size, window_size=window_size, + cache_key=cache_key, force=force, ) return build_response(202) diff --git a/superset/utils/screenshots.py b/superset/utils/screenshots.py index 7f40c0a820..74a1f0746f 100644 --- a/superset/utils/screenshots.py +++ b/superset/utils/screenshots.py @@ -16,6 +16,7 @@ # under the License. from __future__ import annotations +import base64 import logging from datetime import datetime from enum import Enum @@ -64,7 +65,7 @@ class StatusValues(Enum): class ScreenshotCachePayloadType(TypedDict): - image: bytes | None + image: str | None timestamp: str status: str @@ -83,14 +84,16 @@ class ScreenshotCachePayload: @classmethod def from_dict(cls, payload: ScreenshotCachePayloadType) -> ScreenshotCachePayload: return cls( - image=payload["image"], + image=base64.b64decode(payload["image"]) if payload["image"] else None, status=StatusValues(payload["status"]), timestamp=payload["timestamp"], ) def to_dict(self) -> ScreenshotCachePayloadType: return { - "image": self._image, + "image": base64.b64encode(self._image).decode("utf-8") + if self._image + else None, "timestamp": self._timestamp, "status": self.status.value, }
