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

Commit a911dd7

Browse files
Add fields to better debug where events are being soft_failed (#10168)
Follow-up to #10156 (comment)
1 parent 52c60bd commit a911dd7

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

changelog.d/10168.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add extra logging fields to better debug where events are being soft failed.

synapse/handlers/federation.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,11 @@ async def _persist_auth_tree(
24232423
)
24242424

24252425
async def _check_for_soft_fail(
2426-
self, event: EventBase, state: Optional[Iterable[EventBase]], backfilled: bool
2426+
self,
2427+
event: EventBase,
2428+
state: Optional[Iterable[EventBase]],
2429+
backfilled: bool,
2430+
origin: str,
24272431
) -> None:
24282432
"""Checks if we should soft fail the event; if so, marks the event as
24292433
such.
@@ -2432,6 +2436,7 @@ async def _check_for_soft_fail(
24322436
event
24332437
state: The state at the event if we don't have all the event's prev events
24342438
backfilled: Whether the event is from backfill
2439+
origin: The host the event originates from.
24352440
"""
24362441
# For new (non-backfilled and non-outlier) events we check if the event
24372442
# passes auth based on the current state. If it doesn't then we
@@ -2501,7 +2506,17 @@ async def _check_for_soft_fail(
25012506
try:
25022507
event_auth.check(room_version_obj, event, auth_events=current_auth_events)
25032508
except AuthError as e:
2504-
logger.warning("Soft-failing %r because %s", event, e)
2509+
logger.warning(
2510+
"Soft-failing %r (from %s) because %s",
2511+
event,
2512+
e,
2513+
origin,
2514+
extra={
2515+
"room_id": event.room_id,
2516+
"mxid": event.sender,
2517+
"hs": origin,
2518+
},
2519+
)
25052520
soft_failed_event_counter.inc()
25062521
event.internal_metadata.soft_failed = True
25072522

@@ -2614,7 +2629,7 @@ async def _check_event_auth(
26142629
context.rejected = RejectedReason.AUTH_ERROR
26152630

26162631
if not context.rejected:
2617-
await self._check_for_soft_fail(event, state, backfilled)
2632+
await self._check_for_soft_fail(event, state, backfilled, origin=origin)
26182633

26192634
if event.type == EventTypes.GuestAccess and not context.rejected:
26202635
await self.maybe_kick_guest_users(event)

0 commit comments

Comments
 (0)