Fix: Dont crash on imageproxy
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 17 Dec 2025 09:55:56 +0000 (10:55 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 17 Dec 2025 09:55:56 +0000 (10:55 +0100)
music_assistant/controllers/metadata.py

index cee97f01c610b0149cd7cb3c0e2203bce677648f..920a2b3e013fb99f86503b836c694321776f4d25 100644 (file)
@@ -447,7 +447,7 @@ class MetaDataController(CoreController):
         if "%" in path:
             # assume (double) encoded url, decode it
             path = urllib.parse.unquote_plus(path)
-        with suppress(FileNotFoundError):
+        try:
             image_data = await self.get_thumbnail(
                 path, size=size, provider=provider, image_format=image_format
             )
@@ -458,6 +458,17 @@ class MetaDataController(CoreController):
                 headers={"Cache-Control": "max-age=31536000", "Access-Control-Allow-Origin": "*"},
                 content_type=f"image/{image_format}",
             )
+        except Exception as err:
+            # broadly catch all exceptions here to ensure we dont crash the request handler
+            if isinstance(err, FileNotFoundError):
+                self.logger.log(VERBOSE_LOG_LEVEL, "Image not found: %s", path)
+            else:
+                self.logger.warning(
+                    "Error while fetching image %s: %s",
+                    path,
+                    str(err),
+                    exc_info=err if self.logger.isEnabledFor(10) else None,
+                )
         return web.Response(status=404)
 
     async def create_collage_image(