Fix /sync failing when MSC4354 Sticky Events are enabled and the sync request filters out Ephemeral Data Units (EDUs). (#19787)

Fixes: #19779
Fixes: https://github.com/element-hq/synapse/issues/19618

See also: #19786 (which would have caught this, but currently has too
many findings to enable)

Fix UnboundLocalError when MSC4354 is enabled in sync and all EDUs are
filtered out

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
This commit is contained in:
Olivier 'reivilibre
2026-05-18 12:15:57 +01:00
committed by GitHub
parent d8b4ffdf2d
commit 4d0e4ff935
2 changed files with 10 additions and 5 deletions
+1
View File
@@ -0,0 +1 @@
Fix `/sync` failing when [MSC4354 Sticky Events](https://github.com/matrix-org/matrix-spec-proposals/pull/4354) are enabled and the sync request filters out Ephemeral Data Units (EDUs).
+9 -5
View File
@@ -2236,19 +2236,23 @@ class SyncHandler:
if block_all_room_ephemeral:
ephemeral_by_room: dict[str, list[JsonDict]] = {}
else:
now_token, ephemeral_by_room = await self.ephemeral_by_room(
(
sync_result_builder.now_token,
ephemeral_by_room,
) = await self.ephemeral_by_room(
sync_result_builder,
now_token=sync_result_builder.now_token,
since_token=sync_result_builder.since_token,
)
sync_result_builder.now_token = now_token
sticky_by_room: dict[str, list[str]] = {}
if self.hs_config.experimental.msc4354_enabled:
now_token, sticky_by_room = await self.sticky_events_by_room(
sync_result_builder, now_token, since_token
(
sync_result_builder.now_token,
sticky_by_room,
) = await self.sticky_events_by_room(
sync_result_builder, sync_result_builder.now_token, since_token
)
sync_result_builder.now_token = now_token
# 2. We check up front if anything has changed, if it hasn't then there is
# no point in going further.