Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix crash admin media list api when info is None (#14537)
Browse files Browse the repository at this point in the history
Fixes #14536
  • Loading branch information
schmop authored and H-Shay committed Dec 13, 2022
1 parent a3e64b5 commit 08b33b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/14537.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +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.
6 changes: 5 additions & 1 deletion synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,11 @@ def _get_media_mxcs_in_room_txn(
event_json = db_to_json(content_json)
content = event_json["content"]
content_url = content.get("url")
thumbnail_url = content.get("info", {}).get("thumbnail_url")
info = content.get("info")
if isinstance(info, dict):
thumbnail_url = info.get("thumbnail_url")
else:
thumbnail_url = None

for url in (content_url, thumbnail_url):
if not url:
Expand Down

0 comments on commit 08b33b5

Please sign in to comment.