From fabd6fe3e4a4a88c238b877aa989f39706376bc4 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Wed, 13 Nov 2024 14:34:48 +0100 Subject: [PATCH 1/3] Fix bug when rejecting withdrew invite with a third_party_rules module --- synapse/events/snapshot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/synapse/events/snapshot.py b/synapse/events/snapshot.py index dd21a6136b1..6c0542896fa 100644 --- a/synapse/events/snapshot.py +++ b/synapse/events/snapshot.py @@ -269,7 +269,8 @@ async def get_current_state_ids( if self.rejected: raise RuntimeError("Attempt to access state_ids of rejected event") - assert self._state_delta_due_to_event is not None + if self._state_delta_due_to_event is None: + return None prev_state_ids = await self.get_prev_state_ids(state_filter) @@ -300,7 +301,8 @@ async def get_prev_state_ids( this tuple. """ - assert self.state_group_before_event is not None + if self.state_group_before_event is None: + return {} return await self._storage.state.get_state_ids_for_group( self.state_group_before_event, state_filter ) From 17ab62c02d11b322a448296f51a7204e14a98a34 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Wed, 13 Nov 2024 14:58:54 +0100 Subject: [PATCH 2/3] Add changelog --- changelog.d/17930.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17930.bugfix diff --git a/changelog.d/17930.bugfix b/changelog.d/17930.bugfix new file mode 100644 index 00000000000..2e37686857d --- /dev/null +++ b/changelog.d/17930.bugfix @@ -0,0 +1 @@ +Fix bug when rejecting withdrew invite with a third_party_rules module, where the invite would be stuck for the client. From 913235efb6cafe6a90e945ffe901ce9d5bd75873 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Tue, 26 Nov 2024 17:08:27 +0100 Subject: [PATCH 3/3] Adress comment --- synapse/events/snapshot.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/synapse/events/snapshot.py b/synapse/events/snapshot.py index 6c0542896fa..0bca4c188bf 100644 --- a/synapse/events/snapshot.py +++ b/synapse/events/snapshot.py @@ -248,7 +248,7 @@ def state_group(self) -> Optional[int]: @tag_args async def get_current_state_ids( self, state_filter: Optional["StateFilter"] = None - ) -> Optional[StateMap[str]]: + ) -> StateMap[str]: """ Gets the room state map, including this event - ie, the state in ``state_group`` @@ -256,21 +256,19 @@ async def get_current_state_ids( not make it into the room state. This method will raise an exception if ``rejected`` is set. + It is also an error to access this for an outlier event. + Arg: state_filter: specifies the type of state event to fetch from DB, example: EventTypes.JoinRules Returns: - Returns None if state_group is None, which happens when the associated - event is an outlier. - Maps a (type, state_key) to the event ID of the state event matching this tuple. """ if self.rejected: raise RuntimeError("Attempt to access state_ids of rejected event") - if self._state_delta_due_to_event is None: - return None + assert self._state_delta_due_to_event is not None prev_state_ids = await self.get_prev_state_ids(state_filter)