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

Avoid raising errors due to malformed IDs in get_current_hosts_in_room #13748

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13748.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid raising an error due to malformed user IDs in `get_current_hosts_in_room`. Malformed user IDs cannot currently join a room, so this error would not be hit.
5 changes: 4 additions & 1 deletion synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,8 @@ async def get_current_hosts_in_room(self, room_id: str) -> List[str]:
# We use a `Set` just for fast lookups
domain_set: Set[str] = set()
for u in users:
if ":" not in u:
continue
domain = get_domain_from_id(u)
if domain not in domain_set:
domain_set.add(domain)
Expand Down Expand Up @@ -1077,7 +1079,8 @@ def get_current_hosts_in_room_txn(txn: LoggingTransaction) -> List[str]:
ORDER BY min(e.depth) ASC;
"""
txn.execute(sql, (room_id,))
return [d for d, in txn]
# `server_domain` will be `NULL` for malformed MXIDs with no colons.
return [d for d, in txn if d is not None]

return await self.db_pool.runInteraction(
"get_current_hosts_in_room", get_current_hosts_in_room_txn
Expand Down