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

Commit

Permalink
Avoid raising errors due to malformed IDs in `get_current_hosts_in_ro…
Browse files Browse the repository at this point in the history
…om` (#13748)

Handle malformed user IDs with no colons in `get_current_hosts_in_room`.
It's not currently possible for a malformed user ID to join a room, so
this error would never be hit.

Signed-off-by: Sean Quah <seanq@matrix.org>
  • Loading branch information
squahtx authored Sep 8, 2022
1 parent 8ef0c8f commit 89e8b98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 89e8b98

Please sign in to comment.