@@ -1194,10 +1194,17 @@ async def prep(event: EventBase) -> Optional[Tuple[EventBase, EventContext]]:
11941194 auth = {}
11951195 for auth_event_id in event .auth_event_ids ():
11961196 ae = persisted_events .get (auth_event_id )
1197- if ae :
1198- auth [(ae .type , ae .state_key )] = ae
1199- else :
1200- logger .info ("Missing auth event %s" , auth_event_id )
1197+ if not ae :
1198+ logger .warning (
1199+ "Event %s relies on auth_event %s, which could not be found." ,
1200+ event ,
1201+ auth_event_id ,
1202+ )
1203+ # the fact we can't find the auth event doesn't mean it doesn't
1204+ # exist, which means it is premature to reject `event`. Instead we
1205+ # just ignore it for now.
1206+ return None
1207+ auth [(ae .type , ae .state_key )] = ae
12011208
12021209 context = EventContext .for_outlier ()
12031210 context = await self ._check_event_auth (
@@ -1208,8 +1215,10 @@ async def prep(event: EventBase) -> Optional[Tuple[EventBase, EventContext]]:
12081215 )
12091216 return event , context
12101217
1211- events_to_persist = await yieldable_gather_results (prep , fetched_events )
1212- await self .persist_events_and_notify (room_id , events_to_persist )
1218+ events_to_persist = (
1219+ x for x in await yieldable_gather_results (prep , fetched_events ) if x
1220+ )
1221+ await self .persist_events_and_notify (room_id , tuple (events_to_persist ))
12131222
12141223 async def _check_event_auth (
12151224 self ,
@@ -1235,8 +1244,7 @@ async def _check_event_auth(
12351244
12361245 claimed_auth_event_map:
12371246 A map of (type, state_key) => event for the event's claimed auth_events.
1238- Possibly incomplete, and possibly including events that are not yet
1239- persisted, or authed, or in the right room.
1247+ Possibly including events that were rejected, or are in the wrong room.
12401248
12411249 Only populated when populating outliers.
12421250
0 commit comments