Point out which event caused the exception when checking MSC4293 redactions (#19169)

Spawning from looking at the stack trace in
https://github.com/element-hq/synapse/issues/19128 which has no useful
information on how to dig in deeper.
This commit is contained in:
Eric Eastwood 2025-11-13 12:08:22 -06:00 committed by GitHub
parent 47d24bd234
commit 4494cc0694
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 9 deletions

1
changelog.d/19169.misc Normal file
View File

@ -0,0 +1 @@
Point out which event caused the exception when checking [MSC4293](https://github.com/matrix-org/matrix-spec-proposals/pull/4293) redactions.

View File

@ -1600,18 +1600,21 @@ class EventsWorkerStore(SQLBaseStore):
if d:
d.redactions.append(redacter)
# check for MSC4932 redactions
# check for MSC4293 redactions
to_check = []
events: list[_EventRow] = []
for e in evs:
event = event_dict.get(e)
if not event:
continue
events.append(event)
event_json = json.loads(event.json)
room_id = event_json.get("room_id")
user_id = event_json.get("sender")
to_check.append((room_id, user_id))
try:
event = event_dict.get(e)
if not event:
continue
events.append(event)
event_json = json.loads(event.json)
room_id = event_json.get("room_id")
user_id = event_json.get("sender")
to_check.append((room_id, user_id))
except Exception as exc:
raise InvalidEventError(f"Invalid event {event_id}") from exc
# likely that some of these events may be for the same room/user combo, in
# which case we don't need to do redundant queries