summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2021-12-16 17:52:13 -0600
committerEric Eastwood <erice@element.io>2021-12-16 17:52:13 -0600
commitdf2a1523fcecc0f70aeed5e9c4c6bbb51cc06239 (patch)
treef09e684d751fe067aca212b7ce7bf6e6178bc26d
parentClarify comments (diff)
downloadsynapse-df2a1523fcecc0f70aeed5e9c4c6bbb51cc06239.tar.xz
Fix NPE when trying to grab event from wrong roomId (fix sytest)
See https://github.com/matrix-org/synapse/pull/11114#discussion_r741687508
-rw-r--r--synapse/storage/databases/main/event_federation.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index b9d4ef6c20..ef05c67fa0 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -1165,24 +1165,25 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
                 allow_none=True,
             )
 
-            logger.debug(
-                "_get_backfill_events(room_id=%s): seed_event_id=%s depth=%s stream_ordering=%s type=%s",
-                room_id,
-                seed_event_id,
-                event_lookup_result["depth"],
-                event_lookup_result["stream_ordering"],
-                event_lookup_result["type"],
-            )
+            if event_lookup_result is not None:
+                logger.debug(
+                    "_get_backfill_events(room_id=%s): seed_event_id=%s depth=%s stream_ordering=%s type=%s",
+                    room_id,
+                    seed_event_id,
+                    event_lookup_result["depth"],
+                    event_lookup_result["stream_ordering"],
+                    event_lookup_result["type"],
+                )
 
-            if event_lookup_result["depth"]:
-                queue.put(
-                    (
-                        -event_lookup_result["depth"],
-                        -event_lookup_result["stream_ordering"],
-                        seed_event_id,
-                        event_lookup_result["type"],
+                if event_lookup_result["depth"]:
+                    queue.put(
+                        (
+                            -event_lookup_result["depth"],
+                            -event_lookup_result["stream_ordering"],
+                            seed_event_id,
+                            event_lookup_result["type"],
+                        )
                     )
-                )
 
         while not queue.empty() and len(event_id_results) < limit:
             try: