summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-08-10 12:29:47 +0100
committerGitHub <noreply@github.com>2020-08-10 12:29:47 +0100
commitfcbab08cbd46d28976411b1d014a4efb76c8b7a4 (patch)
tree4368a0afbd31457090fc6639f719f63b6b593c4c /synapse/handlers/message.py
parentImplement new experimental push rules (#7997) (diff)
downloadsynapse-fcbab08cbd46d28976411b1d014a4efb76c8b7a4.tar.xz
Add an assertion on prev_events in create_new_client_event (#8041)
I think this would have caught all the cases in
https://github.com/matrix-org/synapse/issues/7642 - and I think a 500 makes
more sense here than a 403
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 708533d4d1..8ddded8389 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -768,6 +768,15 @@ class EventCreationHandler(object):
         else:
             prev_event_ids = await self.store.get_prev_events_for_room(builder.room_id)
 
+        # we now ought to have some prev_events (unless it's a create event).
+        #
+        # do a quick sanity check here, rather than waiting until we've created the
+        # event and then try to auth it (which fails with a somewhat confusing "No
+        # create event in auth events")
+        assert (
+            builder.type == EventTypes.Create or len(prev_event_ids) > 0
+        ), "Attempting to create an event with no prev_events"
+
         event = await builder.build(prev_event_ids=prev_event_ids)
         context = await self.state.compute_event_context(event)
         if requester: