diff --git a/synapse/third_party_rules/access_rules.py b/synapse/third_party_rules/access_rules.py
index 5698e3e062..ac09807738 100644
--- a/synapse/third_party_rules/access_rules.py
+++ b/synapse/third_party_rules/access_rules.py
@@ -511,9 +511,9 @@ class RoomAccessRules(object):
existing_members = []
threepid_invite_tokens = []
for key, state_event in state_events.items():
- if key[0] == EventTypes.Member:
+ if key[0] == EventTypes.Member and state_event.content:
existing_members.append(state_event.state_key)
- if key[0] == EventTypes.ThirdPartyInvite:
+ if key[0] == EventTypes.ThirdPartyInvite and state_event.content:
threepid_invite_tokens.append(state_event.state_key)
# If the event is a state event, there already is an event with the same state key
diff --git a/tests/rest/client/test_room_access_rules.py b/tests/rest/client/test_room_access_rules.py
index bb164c1e5e..8fa828fa15 100644
--- a/tests/rest/client/test_room_access_rules.py
+++ b/tests/rest/client/test_room_access_rules.py
@@ -521,6 +521,16 @@ class RoomAccessTestCase(unittest.HomeserverTestCase):
tok=self.tok,
)
+ invite_token = "someothertoken"
+
+ self.send_state_with_state_key(
+ room_id=self.direct_rooms[1],
+ event_type=EventTypes.ThirdPartyInvite,
+ state_key=invite_token,
+ body=invite_body,
+ tok=self.tok,
+ )
+
def create_room(
self, direct=False, rule=None, preset=RoomCreationPreset.TRUSTED_PRIVATE_CHAT,
initial_state=None, expected_code=200,
|