Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
thumbnail: Improve logging for thumbnail failure case.
Alex Vandiverf53230318144
diff --git a/zerver/tests/test_markdown_thumbnail.py b/zerver/tests/test_markdown_thumbnail.pyindex 1b08f34cc16..768ff0543cc 100644--- a/zerver/tests/test_markdown_thumbnail.py+++ b/zerver/tests/test_markdown_thumbnail.py@@ -344,9 +344,7 @@ class MarkdownThumbnailTest(ZulipTestCase):ensure_thumbnails(ImageAttachment.objects.get(path_id=path_id))thumb_mock.assert_called_once()self.assert_length(thumbnail_logs.output, 1)- self.assertTrue(- thumbnail_logs.output[0].startswith("ERROR:zerver.worker.thumbnail:some bad error")- )+ self.assertIn("some bad error", thumbnail_logs.output[0])self.assertFalse(ImageAttachment.objects.filter(path_id=path_id).exists())self.assert_message_content_is(message_id, f'<p><a href="/user_uploads/{path_id}">image</a></p>'@@ -368,9 +366,7 @@ class MarkdownThumbnailTest(ZulipTestCase):ensure_thumbnails(ImageAttachment.objects.get(path_id=path_id))thumb_mock.assert_called_once()self.assert_length(thumbnail_logs.output, 1)- self.assertTrue(- thumbnail_logs.output[0].startswith("ERROR:zerver.worker.thumbnail:some bad error")- )+ self.assertIn("some bad error", thumbnail_logs.output[0])self.assertFalse(ImageAttachment.objects.filter(path_id=path_id).exists())self.assert_message_content_is(message_id, "<p>Testing </p>")diff --git a/zerver/worker/thumbnail.py b/zerver/worker/thumbnail.pyindex 94bb878732e..a9f422c6453 100644--- a/zerver/worker/thumbnail.py+++ b/zerver/worker/thumbnail.py@@ -166,7 +166,15 @@ def ensure_thumbnails(image_attachment: ImageAttachment) -> ThumbnailingResult:written_images += 1except pyvips.Error as e:- logger.exception(e)+ logger.exception(+ "Failed to thumbnail %s, %d byte %s @ %dx%d: %s",+ image_attachment.path_id,+ len(image_bytes),+ image_attachment.content_type,+ image_attachment.original_width_px,+ image_attachment.original_height_px,+ e.message,+ )if written_images == 0 and len(image_attachment.thumbnail_metadata) == 0:# We have never thumbnailed this -- it most likely had