Skip to content

Commit c2e06c3

Browse files
authored
Fix crash admin media list api when info is None (#14537)
Fixes matrix-org/synapse#14536
1 parent f6c74d1 commit c2e06c3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

changelog.d/14537.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where the [List media admin API](https://matrix-org.github.io/synapse/latest/admin_api/media_admin_api.html#list-all-media-in-a-room) would fail when processing an image with broken thumbnail information.

synapse/storage/databases/main/room.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,11 @@ def _get_media_mxcs_in_room_txn(
912912
event_json = db_to_json(content_json)
913913
content = event_json["content"]
914914
content_url = content.get("url")
915-
thumbnail_url = content.get("info", {}).get("thumbnail_url")
915+
info = content.get("info")
916+
if isinstance(info, dict):
917+
thumbnail_url = info.get("thumbnail_url")
918+
else:
919+
thumbnail_url = None
916920

917921
for url in (content_url, thumbnail_url):
918922
if not url:

0 commit comments

Comments
 (0)