diff --git a/changelog.d/10168.misc b/changelog.d/10168.misc new file mode 100644 index 000000000000..5ca7b89806a2 --- /dev/null +++ b/changelog.d/10168.misc @@ -0,0 +1 @@ +Add extra logging fields to better debug where events are being soft failed. diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 66470634859f..26b7a726a79c 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -2425,7 +2425,11 @@ async def _persist_auth_tree( ) async def _check_for_soft_fail( - self, event: EventBase, state: Optional[Iterable[EventBase]], backfilled: bool + self, + event: EventBase, + state: Optional[Iterable[EventBase]], + backfilled: bool, + origin: str, ) -> None: """Checks if we should soft fail the event; if so, marks the event as such. @@ -2434,6 +2438,7 @@ async def _check_for_soft_fail( event state: The state at the event if we don't have all the event's prev events backfilled: Whether the event is from backfill + origin: The host the event originates from. """ # For new (non-backfilled and non-outlier) events we check if the event # passes auth based on the current state. If it doesn't then we @@ -2503,7 +2508,17 @@ async def _check_for_soft_fail( try: event_auth.check(room_version_obj, event, auth_events=current_auth_events) except AuthError as e: - logger.warning("Soft-failing %r because %s", event, e) + logger.warning( + "Soft-failing %r (from %s) because %s", + event, + e, + origin, + extra={ + "room_id": event.room_id, + "mxid": event.sender, + "hs": origin, + }, + ) soft_failed_event_counter.inc() event.internal_metadata.soft_failed = True @@ -2616,7 +2631,7 @@ async def _check_event_auth( context.rejected = RejectedReason.AUTH_ERROR if not context.rejected: - await self._check_for_soft_fail(event, state, backfilled) + await self._check_for_soft_fail(event, state, backfilled, origin=origin) if event.type == EventTypes.GuestAccess and not context.rejected: await self.maybe_kick_guest_users(event)