From 7b0e31146cc7200eb22efbd73e4b7f8ad93e6ad9 Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Wed, 28 Sep 2022 15:46:09 +0100 Subject: [PATCH] Always ensure we return a value for every user in `get_rooms_for_users` The cached list (sensibly) requires that every input value has a corresponding output. --- synapse/storage/databases/main/roommember.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index 0965f8ca5f08..982e1f08e30b 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -from collections import defaultdict from typing import ( TYPE_CHECKING, Collection, @@ -696,7 +695,8 @@ async def get_rooms_for_users( desc="get_rooms_for_users", ) - user_rooms: Dict[str, Set[str]] = defaultdict(set) + user_rooms: Dict[str, Set[str]] = {user_id: set() for user_id in user_ids} + for row in rows: user_rooms[row["state_key"]].add(row["room_id"])