From cfb32b2e130217baba008907a589f7eeb1534b8d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 2 Oct 2020 12:13:30 -0400 Subject: [PATCH 1/2] Handle event.redacts being None. --- changelog.d/8457.bugfix | 1 + synapse/event_auth.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8457.bugfix diff --git a/changelog.d/8457.bugfix b/changelog.d/8457.bugfix new file mode 100644 index 000000000000..545b06d180c1 --- /dev/null +++ b/changelog.d/8457.bugfix @@ -0,0 +1 @@ +Fix a bug where backfilling a room with an event that was missing the `redacts` field would break. diff --git a/synapse/event_auth.py b/synapse/event_auth.py index 8c907ad5969a..0b67a59118ac 100644 --- a/synapse/event_auth.py +++ b/synapse/event_auth.py @@ -446,7 +446,9 @@ def check_redaction( if room_version_obj.event_format == EventFormatVersions.V1: redacter_domain = get_domain_from_id(event.event_id) - redactee_domain = get_domain_from_id(event.redacts) + redactee_domain = None + if event.redacts: + redactee_domain = get_domain_from_id(event.redacts) if redacter_domain == redactee_domain: return True else: From 412ba51a56384cf419ac5ab63a5c3e439b1ccd07 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 5 Oct 2020 09:15:06 -0400 Subject: [PATCH 2/2] Apply suggestions from code review. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- synapse/event_auth.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/event_auth.py b/synapse/event_auth.py index 0b67a59118ac..56f8dc9caf9e 100644 --- a/synapse/event_auth.py +++ b/synapse/event_auth.py @@ -446,9 +446,9 @@ def check_redaction( if room_version_obj.event_format == EventFormatVersions.V1: redacter_domain = get_domain_from_id(event.event_id) - redactee_domain = None - if event.redacts: - redactee_domain = get_domain_from_id(event.redacts) + if not isinstance(event.redacts, str): + return False + redactee_domain = get_domain_from_id(event.redacts) if redacter_domain == redactee_domain: return True else: