Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overly restrictive typeguards in get_rooms_that_allow_join #18066

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/18066.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug that caused new space-visible rooms to be hidden from the space hierarchy when any server modules are loaded.
6 changes: 4 additions & 2 deletions synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import logging
from typing import TYPE_CHECKING, List, Mapping, Optional, Union

from immutabledict import immutabledict

from synapse import event_auth
from synapse.api.constants import (
EventTypes,
Expand Down Expand Up @@ -326,13 +328,13 @@ async def get_rooms_that_allow_join(

# If allowed is of the wrong form, then only allow invited users.
allow_list = join_rules_event.content.get("allow", [])
if not isinstance(allow_list, list):
if not isinstance(allow_list, (list, tuple)):
return ()

# Pull out the other room IDs, invalid data gets filtered.
result = []
for allow in allow_list:
if not isinstance(allow, dict):
if not isinstance(allow, (immutabledict, dict)):
continue

# If the type is unexpected, skip it.
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/room_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def as_json(self, for_client: bool = False) -> JsonDict:

def _has_valid_via(e: EventBase) -> bool:
via = e.content.get("via")
if not via or not isinstance(via, list):
if not via or not isinstance(via, (list, tuple)):
return False
for v in via:
if not isinstance(v, str):
Expand Down