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

Conversation

blackmad
Copy link

@blackmad blackmad commented Jan 6, 2025

This was causing a bug that was only occuring when the server had modules loaded and there were unjoined space-visible rooms in a hierarchy.

This fix is a result of the following investigation:

Symptom: new 'space-visible' rooms are not showing up in /hierarchy Reason: because get_rooms_that_allow_join is checking that the allow key is a list, and it's coming back as a tuple synapse/handlers/event_auth.py#L329

Reason: when the room is created, the join_rules event creation logic calls check_event_allowed - synapse/handlers/message.py#L1289 - which calls event.freeze() (in synapse/module_api/callbacks/third_party_event_rules_callbacks.py#L294 ) which seems to be changing lists to tuples - so that when the event is being pulled from cache, the allow list is a tuple. But when I restart the server, it gets pulled from the DB and deserialized as a list.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

This was causing a bug that was only occuring when the server had modules loaded and there were unjoined space-visible rooms in a hierarchy.

This fix is a result of the following investigation:
Symptom: new 'space-visible' rooms are not showing up in /hierarchy
Reason: because get_rooms_that_allow_join is checking that the allow key is a list, and it's coming back as a tuple https://github.com/element-hq/synapse/blob/develop/synapse/handlers/event_auth.py#L329

-> Reason: when the room is created, the join_rules event calls check_event_allowed - https://github.com/element-hq/synapse/blob/develop/synapse/handlers/message.py#L1289 - which calls event.freeze() which seems to be changing lists to tuples - https://github.com/element-hq/synapse/blob/develop/synapse/module_api/callbacks/third_party_event_rules_callbacks.py#L294
--> so that when the event is being pulled from cache, the allow list is a tuple. But when I restart the server, it gets pulled from the DB and deserialized as a list.
@blackmad blackmad requested a review from a team as a code owner January 6, 2025 10:27
@CLAassistant
Copy link

CLAassistant commented Jan 6, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants