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

Commit 43f1c82

Browse files
authored
Add back the guard against the user directory stream position not existing. (#9428)
As the comment says, this guard was there for when the initial user directory update has yet to happen.
1 parent 626afd7 commit 43f1c82

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

changelog.d/9428.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug introduced in v1.27.0: "TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType." related to the user directory.

synapse/handlers/user_directory.py

+4
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ async def _unsafe_process(self) -> None:
143143
if self.pos is None:
144144
self.pos = await self.store.get_user_directory_stream_pos()
145145

146+
# If still None then the initial background update hasn't happened yet.
147+
if self.pos is None:
148+
return None
149+
146150
# Loop round handling deltas until we're up to date
147151
while True:
148152
with Measure(self.clock, "user_dir_delta"):

synapse/storage/databases/main/user_directory.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,13 @@ def _get_shared_rooms_for_users_txn(txn):
707707

708708
return {row["room_id"] for row in rows}
709709

710-
async def get_user_directory_stream_pos(self) -> int:
710+
async def get_user_directory_stream_pos(self) -> Optional[int]:
711+
"""
712+
Get the stream ID of the user directory stream.
713+
714+
Returns:
715+
The stream token or None if the initial background update hasn't happened yet.
716+
"""
711717
return await self.db_pool.simple_select_one_onecol(
712718
table="user_directory_stream_pos",
713719
keyvalues={},

0 commit comments

Comments
 (0)