Skip to content

Allow 3rd party rules check_event_allowed callback to function for room version "12" creation events#19768

Open
jason-famedly wants to merge 3 commits into
element-hq:developfrom
famedly:jason/3rd-party-rules-v12-rooms
Open

Allow 3rd party rules check_event_allowed callback to function for room version "12" creation events#19768
jason-famedly wants to merge 3 commits into
element-hq:developfrom
famedly:jason/3rd-party-rules-v12-rooms

Conversation

@jason-famedly
Copy link
Copy Markdown
Contributor

@jason-famedly jason-famedly commented May 11, 2026

The change to room version "12" removes that a room ID is included in the room creation event, and is instead generated based on the event hash of said event. This seems to break the check_event_allowed() callback for this room version specifically for creation events due to an assert in the function that expects a room ID to be present.

Specifically ignore that assertion for creation events on rooms that support MSC4291(Room ID's as hashes) to fix this. This also needs to be checked for the correct assumptions about MSC4242 taken in it's second half(that creation events do not contain prev_state_events in the same way that they do not include prev_events)

Note this contains a commit that should be reverted before merging, that overrides the test so room version "12" is used

💡 This is the command line to run the specific test:
poetry run trial tests.rest.client.test_third_party_rules.ThirdPartyRulesTestCase.test_legacy_check_event_allowed

Failure looked like this before:
[ERROR]
Traceback (most recent call last):
  File "/home/jason/dev/famedly/synapse-upstreaming/tests/rest/client/test_third_party_rules.py", line 394, in test_legacy_check_event_allowed
    "/_matrix/client/r0/rooms/%s/send/m.room.message/1" % self.room_id,
builtins.AttributeError: 'ThirdPartyRulesTestCase' object has no attribute 'room_id'

tests.rest.client.test_third_party_rules.ThirdPartyRulesTestCase.test_legacy_check_event_allowed
===============================================================================

(There is another error in this TestCase when using room version "12", but it is unrelated to this and will be handled separately when fixing the tests themselves)

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)

@jason-famedly jason-famedly marked this pull request as ready for review May 11, 2026 13:34
@jason-famedly jason-famedly requested a review from a team as a code owner May 11, 2026 13:34
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.

1 participant