Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix unbound access of `log` (when the captured exception is a timeout) (#4889)

sarayourfriendde091babaf6c
diff --git a/api/api/utils/image_proxy/extension.py b/api/api/utils/image_proxy/extension.py
index 3c2e24569..10dd70f6a 100644
--- a/api/api/utils/image_proxy/extension.py
+++ b/api/api/utils/image_proxy/extension.py
@@ -91,7 +91,7 @@ async def get_image_extension(media_info: MediaInfo) -> str | None:
else:
log = logger.error
- log("upstream_thumbnail_exception", exc=exc, exc_info=True)
+ log("upstream_thumbnail_exception", exc=exc, exc_info=True)
raise UpstreamThumbnailException(
"Failed to render thumbnail due to inability to check media "
diff --git a/api/test/unit/utils/test_image_proxy.py b/api/test/unit/utils/test_image_proxy.py
index 044b4b395..e1d10932d 100644
--- a/api/test/unit/utils/test_image_proxy.py
+++ b/api/test/unit/utils/test_image_proxy.py
@@ -1,3 +1,4 @@
+import asyncio
import contextlib
from dataclasses import replace
from urllib.parse import urlencode
@@ -336,8 +337,8 @@ MOCK_CONNECTION_KEY = ConnectionKey(
"aiohttp.client_exceptions.ClientConnectionError",
),
(
- client_exceptions.ServerTimeoutError("whoops"),
- "aiohttp.client_exceptions.ServerTimeoutError",
+ asyncio.TimeoutError("whoops"),
+ "builtins.TimeoutError",
),
(
client_exceptions.ClientSSLError(MOCK_CONNECTION_KEY, OSError()),