Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,10 +1342,32 @@ def thumbnail(self, pk: int, digest: str, **kwargs: Any) -> WerkzeugResponse:
self.incr_stats("from_cache", self.thumbnail.__name__)
try:
image = cache_payload.get_image()
# Validate the BytesIO object is properly initialized
if not image or not hasattr(image, "read"):
logger.warning(
"Thumbnail image object is invalid for dashboard %s",
str(dashboard.id),
)
return self.response_404()
# Additional validation: ensure the BytesIO has content
if image.getbuffer().nbytes == 0:
logger.warning(
"Thumbnail image is empty for dashboard %s",
str(dashboard.id),
)
return self.response_404()
# Reset position to ensure reading from start
image.seek(0)
except ScreenshotImageNotAvailableException:
return self.response_404()
except Exception as ex: # pylint: disable=broad-except
logger.error(
"Error retrieving thumbnail for dashboard %s: %s",
str(dashboard.id),
str(ex),
exc_info=True,
)
return self.response_404()
return Response(
FileWrapper(image),
mimetype="image/png",
Expand Down
Loading