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

Commit 1f32b90

Browse files
authored
Room batch: fix up handling of unknown prev_event_ids (#12316)
1 parent 8a519f8 commit 1f32b90

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

changelog.d/12316.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid trying to calculate the state at outlier events.

synapse/rest/client/room_batch.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ async def on_POST(
123123
errcode=Codes.INVALID_PARAM,
124124
)
125125

126+
# Make sure that the prev_event_ids exist and aren't outliers - ie, they are
127+
# regular parts of the room DAG where we know the state.
128+
non_outlier_prev_events = await self.store.have_events_in_timeline(
129+
prev_event_ids_from_query
130+
)
131+
for prev_event_id in prev_event_ids_from_query:
132+
if prev_event_id not in non_outlier_prev_events:
133+
raise SynapseError(
134+
HTTPStatus.BAD_REQUEST,
135+
"prev_event %s does not exist, or is an outlier" % (prev_event_id,),
136+
errcode=Codes.INVALID_PARAM,
137+
)
138+
126139
# For the event we are inserting next to (`prev_event_ids_from_query`),
127140
# find the most recent state events that allowed that message to be
128141
# sent. We will use that as a base to auth our historical messages
@@ -131,14 +144,6 @@ async def on_POST(
131144
prev_event_ids_from_query
132145
)
133146

134-
if not state_event_ids:
135-
raise SynapseError(
136-
HTTPStatus.BAD_REQUEST,
137-
"No auth events found for given prev_event query parameter. The prev_event=%s probably does not exist."
138-
% prev_event_ids_from_query,
139-
errcode=Codes.INVALID_PARAM,
140-
)
141-
142147
state_event_ids_at_start = []
143148
# Create and persist all of the state events that float off on their own
144149
# before the batch. These will most likely be all of the invite/member

0 commit comments

Comments
 (0)