From 7b725988cea01b689fc783111f0af2d29afc34ea Mon Sep 17 00:00:00 2001 From: Yorusaka Miyabi <23130178+ShadowRZ@users.noreply.github.com> Date: Mon, 14 Jul 2025 12:52:50 +0800 Subject: [PATCH 01/14] Change default room version to 11. implments MSC4239 --- docs/usage/configuration/config_documentation.md | 4 +++- schema/synapse-config.schema.yaml | 6 +++++- synapse/config/server.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 1fff68ed0a1..0ef3035c2e0 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -342,7 +342,9 @@ For example, for room version 1, `default_room_version` should be set to "1". _Changed in Synapse 1.76:_ the default version room version was increased from [9](https://spec.matrix.org/v1.5/rooms/v9/) to [10](https://spec.matrix.org/v1.5/rooms/v10/). -Defaults to `"10"`. +_Changed in Synapse 1.134:_ the default version room version was increased from [9](https://spec.matrix.org/v1.12/rooms/v10/) to [10](https://spec.matrix.org/v1.12/rooms/v11/). + +Defaults to `"11"`. Example configuration: ```yaml diff --git a/schema/synapse-config.schema.yaml b/schema/synapse-config.schema.yaml index 26f0e7f0bcf..e350fc3f93d 100644 --- a/schema/synapse-config.schema.yaml +++ b/schema/synapse-config.schema.yaml @@ -265,7 +265,11 @@ properties: _Changed in Synapse 1.76:_ the default version room version was increased from [9](https://spec.matrix.org/v1.5/rooms/v9/) to [10](https://spec.matrix.org/v1.5/rooms/v10/). - default: "10" + + _Changed in Synapse 1.134:_ the default version room version was increased + from [10](https://spec.matrix.org/v1.12/rooms/v10/) to + [11](https://spec.matrix.org/v1.12/rooms/v11/). + default: "11" examples: - "8" gc_thresholds: diff --git a/synapse/config/server.py b/synapse/config/server.py index 68934509890..c1cd37dc568 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py @@ -158,7 +158,7 @@ def generate_ip_set( "fec0::/10", ] -DEFAULT_ROOM_VERSION = "10" +DEFAULT_ROOM_VERSION = "11" ROOM_COMPLEXITY_TOO_GREAT = ( "Your homeserver is unable to join rooms this large or complex. " From f58d9d1c371d4645480f922b0ac8d89194141fd8 Mon Sep 17 00:00:00 2001 From: Yorusaka Miyabi <23130178+ShadowRZ@users.noreply.github.com> Date: Mon, 14 Jul 2025 13:03:50 +0800 Subject: [PATCH 02/14] Add changelog file --- changelog.d/18680.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/18680.feature diff --git a/changelog.d/18680.feature b/changelog.d/18680.feature new file mode 100644 index 00000000000..1c8fe2bf8ed --- /dev/null +++ b/changelog.d/18680.feature @@ -0,0 +1 @@ +Change default room version to 11, implmenting [MSC4239](https://github.com/matrix-org/matrix-spec-proposals/pull/4239). From 258a7e00e69bcb55c598e8998fe8071e74f9cc2d Mon Sep 17 00:00:00 2001 From: reivilibre Date: Tue, 15 Jul 2025 11:37:20 +0100 Subject: [PATCH 03/14] Update changelog.d/18680.feature --- changelog.d/18680.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/18680.feature b/changelog.d/18680.feature index 1c8fe2bf8ed..e4280d46789 100644 --- a/changelog.d/18680.feature +++ b/changelog.d/18680.feature @@ -1 +1 @@ -Change default room version to 11, implmenting [MSC4239](https://github.com/matrix-org/matrix-spec-proposals/pull/4239). +Change default room version to 11, implementing [MSC4239](https://github.com/matrix-org/matrix-spec-proposals/pull/4239) as part of Matrix v1.14. From 89e478e7dfcd67aff26471900ca204921622e621 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Tue, 15 Jul 2025 11:41:30 +0100 Subject: [PATCH 04/14] fixup config doc --- docs/usage/configuration/config_documentation.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 0ef3035c2e0..1793e8ebab6 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -341,8 +341,7 @@ Known room versions are listed [here](https://spec.matrix.org/latest/rooms/#comp For example, for room version 1, `default_room_version` should be set to "1". _Changed in Synapse 1.76:_ the default version room version was increased from [9](https://spec.matrix.org/v1.5/rooms/v9/) to [10](https://spec.matrix.org/v1.5/rooms/v10/). - -_Changed in Synapse 1.134:_ the default version room version was increased from [9](https://spec.matrix.org/v1.12/rooms/v10/) to [10](https://spec.matrix.org/v1.12/rooms/v11/). +_Changed in Synapse 1.134:_ the default version room version was increased from [10](https://spec.matrix.org/v1.12/rooms/v10/) to [11](https://spec.matrix.org/v1.12/rooms/v11/). Defaults to `"11"`. From a9cd65c8b27360bd39d9b55b6dd53a1b67c23d7c Mon Sep 17 00:00:00 2001 From: Yorusaka Miyabi <23130178+ShadowRZ@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:01:01 +0800 Subject: [PATCH 05/14] Fix unittests --- .../test_federation_out_of_band_membership.py | 5 +---- tests/module_api/test_api.py | 18 ------------------ .../client/sliding_sync/test_rooms_invites.py | 8 ++++---- tests/rest/client/test_redactions.py | 2 +- tests/storage/databases/main/test_room.py | 2 +- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/tests/federation/test_federation_out_of_band_membership.py b/tests/federation/test_federation_out_of_band_membership.py index f77b8fe3005..b8668ffacc8 100644 --- a/tests/federation/test_federation_out_of_band_membership.py +++ b/tests/federation/test_federation_out_of_band_membership.py @@ -193,7 +193,7 @@ def _invite_local_user_to_remote_room_and_join(self) -> RemoteRoomJoinResult: # Create a remote room room_creator_user_id = f"@remote-user:{self.OTHER_SERVER_NAME}" remote_room_id = f"!remote-room:{self.OTHER_SERVER_NAME}" - room_version = RoomVersions.V10 + room_version = RoomVersions.V11 room_create_event = make_event_from_dict( self.add_hashes_and_signatures_from_other_server( @@ -205,9 +205,6 @@ def _invite_local_user_to_remote_room_and_join(self) -> RemoteRoomJoinResult: "type": EventTypes.Create, "state_key": "", "content": { - # The `ROOM_CREATOR` field could be removed if we used a room - # version > 10 (in favor of relying on `sender`) - EventContentFields.ROOM_CREATOR: room_creator_user_id, EventContentFields.ROOM_VERSION: room_version.identifier, }, "auth_events": [], diff --git a/tests/module_api/test_api.py b/tests/module_api/test_api.py index b6ba472d7d4..1354373294c 100644 --- a/tests/module_api/test_api.py +++ b/tests/module_api/test_api.py @@ -751,15 +751,6 @@ def test_create_room(self) -> None: ) ) - # Check room creator. - channel = self.make_request( - "GET", - f"/_matrix/client/v3/rooms/{room_id}/state/m.room.create", - access_token=access_token, - ) - self.assertEqual(channel.code, 200, channel.result) - self.assertEqual(channel.json_body["creator"], user_id) - # Check room alias. self.assertEqual(room_alias, f"#foo-bar:{self.module_api.server_name}") @@ -768,15 +759,6 @@ def test_create_room(self) -> None: self.module_api.create_room(user_id=user_id, config={}, ratelimit=False) ) - # Check room creator. - channel = self.make_request( - "GET", - f"/_matrix/client/v3/rooms/{room_id}/state/m.room.create", - access_token=access_token, - ) - self.assertEqual(channel.code, 200, channel.result) - self.assertEqual(channel.json_body["creator"], user_id) - # Check room alias. self.assertIsNone(room_alias) diff --git a/tests/rest/client/sliding_sync/test_rooms_invites.py b/tests/rest/client/sliding_sync/test_rooms_invites.py index 882762ca29a..25b553a9fbe 100644 --- a/tests/rest/client/sliding_sync/test_rooms_invites.py +++ b/tests/rest/client/sliding_sync/test_rooms_invites.py @@ -143,7 +143,7 @@ def test_rooms_invite_shared_history_initial_sync(self) -> None: response_body["rooms"][room_id1]["invite_state"], [ { - "content": {"creator": user2_id, "room_version": "10"}, + "content": {"room_version": "11"}, "sender": user2_id, "state_key": "", "type": "m.room.create", @@ -253,7 +253,7 @@ def test_rooms_invite_shared_history_incremental_sync(self) -> None: response_body["rooms"][room_id1]["invite_state"], [ { - "content": {"creator": user2_id, "room_version": "10"}, + "content": {"room_version": "11"}, "sender": user2_id, "state_key": "", "type": "m.room.create", @@ -374,7 +374,7 @@ def test_rooms_invite_world_readable_history_initial_sync(self) -> None: response_body["rooms"][room_id1]["invite_state"], [ { - "content": {"creator": user2_id, "room_version": "10"}, + "content": {"room_version": "11"}, "sender": user2_id, "state_key": "", "type": "m.room.create", @@ -500,7 +500,7 @@ def test_rooms_invite_world_readable_history_incremental_sync(self) -> None: response_body["rooms"][room_id1]["invite_state"], [ { - "content": {"creator": user2_id, "room_version": "10"}, + "content": {"room_version": "11"}, "sender": user2_id, "state_key": "", "type": "m.room.create", diff --git a/tests/rest/client/test_redactions.py b/tests/rest/client/test_redactions.py index b25e1847862..831e5d9af10 100644 --- a/tests/rest/client/test_redactions.py +++ b/tests/rest/client/test_redactions.py @@ -64,7 +64,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Create a room self.room_id = self.helper.create_room_as( - self.mod_user_id, tok=self.mod_access_token + self.mod_user_id, tok=self.mod_access_token, room_version="10" ) # Invite the other user diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 88a5aa8cb17..ed6820279fe 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -47,7 +47,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: def _generate_room(self) -> str: """Create a room and return the room ID.""" - return self.helper.create_room_as(self.user_id, tok=self.token) + return self.helper.create_room_as(self.user_id, tok=self.token, room_version="10") def run_background_updates(self, update_name: str) -> None: """Insert and run the background update.""" From e4d5c98f394648f0e702e4bd4a9ee3b4d65fd457 Mon Sep 17 00:00:00 2001 From: Yorusaka Miyabi <23130178+ShadowRZ@users.noreply.github.com> Date: Wed, 16 Jul 2025 16:08:08 +0800 Subject: [PATCH 06/14] Fix code style violations --- tests/module_api/test_api.py | 1 - tests/storage/databases/main/test_room.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/module_api/test_api.py b/tests/module_api/test_api.py index 1354373294c..1a211f573bf 100644 --- a/tests/module_api/test_api.py +++ b/tests/module_api/test_api.py @@ -743,7 +743,6 @@ def test_create_room(self) -> None: # Now do the happy path. user_id = self.register_user("user", "password") - access_token = self.login(user_id, "password") room_id, room_alias = self.get_success( self.module_api.create_room( diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index ed6820279fe..97a6383b66b 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -47,7 +47,9 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: def _generate_room(self) -> str: """Create a room and return the room ID.""" - return self.helper.create_room_as(self.user_id, tok=self.token, room_version="10") + return self.helper.create_room_as( + self.user_id, tok=self.token, room_version="10" + ) def run_background_updates(self, update_name: str) -> None: """Insert and run the background update.""" From 8ffce4656e404b7771bc387a692db9f6eabd56ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Wed, 8 Jul 2026 16:38:03 +0800 Subject: [PATCH 07/14] Update mentioned Synapse versions for the default room version change --- docs/usage/configuration/config_documentation.md | 2 +- schema/synapse-config.schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 1793e8ebab6..6f3aad5334b 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -341,7 +341,7 @@ Known room versions are listed [here](https://spec.matrix.org/latest/rooms/#comp For example, for room version 1, `default_room_version` should be set to "1". _Changed in Synapse 1.76:_ the default version room version was increased from [9](https://spec.matrix.org/v1.5/rooms/v9/) to [10](https://spec.matrix.org/v1.5/rooms/v10/). -_Changed in Synapse 1.134:_ the default version room version was increased from [10](https://spec.matrix.org/v1.12/rooms/v10/) to [11](https://spec.matrix.org/v1.12/rooms/v11/). +_Changed in Synapse 1.157:_ the default version room version was increased from [10](https://spec.matrix.org/v1.12/rooms/v10/) to [11](https://spec.matrix.org/v1.12/rooms/v11/). Defaults to `"11"`. diff --git a/schema/synapse-config.schema.yaml b/schema/synapse-config.schema.yaml index e350fc3f93d..398378bd209 100644 --- a/schema/synapse-config.schema.yaml +++ b/schema/synapse-config.schema.yaml @@ -266,7 +266,7 @@ properties: from [9](https://spec.matrix.org/v1.5/rooms/v9/) to [10](https://spec.matrix.org/v1.5/rooms/v10/). - _Changed in Synapse 1.134:_ the default version room version was increased + _Changed in Synapse 1.157:_ the default version room version was increased from [10](https://spec.matrix.org/v1.12/rooms/v10/) to [11](https://spec.matrix.org/v1.12/rooms/v11/). default: "11" From bde3d5450e5ff1fbd8e1d1c2b072dc79b706e186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Wed, 8 Jul 2026 22:22:49 +0800 Subject: [PATCH 08/14] Fix all MSC4293RedactOnBanKickTestCase tests for room version 11 --- tests/rest/client/test_rooms.py | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 8d4892ae91f..23c9678eb8f 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -4720,7 +4720,7 @@ def test_banning_remote_member_with_flag_redacts_their_events(self) -> None: bad_user = "@remote_bad_user:" + self.OTHER_SERVER_NAME channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -4728,7 +4728,7 @@ def test_banning_remote_member_with_flag_redacts_their_events(self) -> None: join_event_dict = join_result["event"] self.add_hashes_and_signatures_from_other_server( join_event_dict, - RoomVersions.V10, + RoomVersions.V11, ) channel = self.make_signed_federation_request( "PUT", @@ -4763,7 +4763,7 @@ def test_banning_remote_member_with_flag_redacts_their_events(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -4814,7 +4814,7 @@ def test_banning_remote_member_with_flag_redacts_their_events(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -4839,7 +4839,7 @@ def test_unbanning_remote_user_stops_redaction_action(self) -> None: bad_user = "@remote_bad_user:" + self.OTHER_SERVER_NAME channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -4847,7 +4847,7 @@ def test_unbanning_remote_user_stops_redaction_action(self) -> None: join_event_dict = join_result["event"] self.add_hashes_and_signatures_from_other_server( join_event_dict, - RoomVersions.V10, + RoomVersions.V11, ) channel = self.make_signed_federation_request( "PUT", @@ -4882,7 +4882,7 @@ def test_unbanning_remote_user_stops_redaction_action(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -4923,7 +4923,7 @@ def test_unbanning_remote_user_stops_redaction_action(self) -> None: # user should be able to join again channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -4971,7 +4971,7 @@ def test_unbanning_remote_user_stops_redaction_action(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -5085,7 +5085,7 @@ def test_kicking_remote_member_with_flag_redacts_their_events(self) -> None: bad_user = "@remote_bad_user:" + self.OTHER_SERVER_NAME channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -5093,7 +5093,7 @@ def test_kicking_remote_member_with_flag_redacts_their_events(self) -> None: join_event_dict = join_result["event"] self.add_hashes_and_signatures_from_other_server( join_event_dict, - RoomVersions.V10, + RoomVersions.V11, ) channel = self.make_signed_federation_request( "PUT", @@ -5128,7 +5128,7 @@ def test_kicking_remote_member_with_flag_redacts_their_events(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -5179,7 +5179,7 @@ def test_kicking_remote_member_with_flag_redacts_their_events(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -5201,7 +5201,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: bad_user = "@remote_bad_user:" + self.OTHER_SERVER_NAME channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -5209,7 +5209,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: join_event_dict = join_result["event"] self.add_hashes_and_signatures_from_other_server( join_event_dict, - RoomVersions.V10, + RoomVersions.V11, ) channel = self.make_signed_federation_request( "PUT", @@ -5244,7 +5244,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( @@ -5280,7 +5280,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: # user re-joins after kick channel = self.make_signed_federation_request( "GET", - f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=10", + f"/_matrix/federation/v1/make_join/{self.room_id}/{bad_user}?ver=11", ) self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body) join_result = channel.json_body @@ -5288,7 +5288,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: join_event_dict = join_result["event"] self.add_hashes_and_signatures_from_other_server( join_event_dict, - RoomVersions.V10, + RoomVersions.V11, ) channel = self.make_signed_federation_request( "PUT", @@ -5328,7 +5328,7 @@ def test_rejoining_kicked_remote_user_stops_redaction_action(self) -> None: "prev_events": auth_ids, } ), - room_version=RoomVersions.V10, + room_version=RoomVersions.V11, ) self.get_success( From de257aa47a04699c87075c38d031500ddfb561d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Thu, 9 Jul 2026 11:33:40 +0800 Subject: [PATCH 09/14] Add explations for room version 11 exceptions --- tests/rest/client/test_redactions.py | 3 +++ tests/storage/databases/main/test_room.py | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/rest/client/test_redactions.py b/tests/rest/client/test_redactions.py index e5884301b38..761931a5c14 100644 --- a/tests/rest/client/test_redactions.py +++ b/tests/rest/client/test_redactions.py @@ -63,6 +63,9 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Create a room self.room_id = self.helper.create_room_as( + # FIXME: Using room version 10 here as using later version requires + # https://github.com/element-hq/synapse/pull/19782 + # Remove the override when the above PR is merged. self.mod_user_id, tok=self.mod_access_token, room_version="10" ) diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 19d728b5247..600f00074c7 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -48,6 +48,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: def _generate_room(self) -> str: """Create a room and return the room ID.""" return self.helper.create_room_as( + # FIXME: Room version 11 breaks test_background_populate_rooms_creator_column self.user_id, tok=self.token, room_version="10" ) From ce21fd9822b74c9a1c1c9e3e50d791ebbffe352f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Sat, 11 Jul 2026 08:53:06 +0800 Subject: [PATCH 10/14] Fix lint failures --- tests/rest/client/test_redactions.py | 4 +++- tests/storage/databases/main/test_room.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/rest/client/test_redactions.py b/tests/rest/client/test_redactions.py index 761931a5c14..a506121538c 100644 --- a/tests/rest/client/test_redactions.py +++ b/tests/rest/client/test_redactions.py @@ -66,7 +66,9 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # FIXME: Using room version 10 here as using later version requires # https://github.com/element-hq/synapse/pull/19782 # Remove the override when the above PR is merged. - self.mod_user_id, tok=self.mod_access_token, room_version="10" + self.mod_user_id, + tok=self.mod_access_token, + room_version="10", ) # Invite the other user diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 600f00074c7..6be20ee3d69 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -49,7 +49,9 @@ def _generate_room(self) -> str: """Create a room and return the room ID.""" return self.helper.create_room_as( # FIXME: Room version 11 breaks test_background_populate_rooms_creator_column - self.user_id, tok=self.token, room_version="10" + self.user_id, + tok=self.token, + room_version="10", ) def run_background_updates(self, update_name: str) -> None: From 98dc2affd019c6917cc837ff3a0213aa42618269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:12:37 +0800 Subject: [PATCH 11/14] Explain the case for room version 11 breaking test_background_populate_rooms_creator_column --- tests/storage/databases/main/test_room.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 6be20ee3d69..f3188be1be3 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -49,6 +49,8 @@ def _generate_room(self) -> str: """Create a room and return the room ID.""" return self.helper.create_room_as( # FIXME: Room version 11 breaks test_background_populate_rooms_creator_column + # Since room version 11 removes `creator` field, it never got populated + # to the database, thus breaking that test self.user_id, tok=self.token, room_version="10", From 68fde187f21dd4e7d4da08f3132e5486b469dbd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Wed, 15 Jul 2026 15:45:41 +0800 Subject: [PATCH 12/14] Add per test room version in RoomBackgroundUpdateStoreTestCase Also use room version 10 for test_background_populate_rooms_creator_column. --- tests/storage/databases/main/test_room.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index f3188be1be3..6feb2f595b2 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -45,15 +45,12 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.user_id = self.register_user("foo", "pass") self.token = self.login("foo", "pass") - def _generate_room(self) -> str: + def _generate_room(self, room_version: str = "11") -> str: """Create a room and return the room ID.""" return self.helper.create_room_as( - # FIXME: Room version 11 breaks test_background_populate_rooms_creator_column - # Since room version 11 removes `creator` field, it never got populated - # to the database, thus breaking that test self.user_id, tok=self.token, - room_version="10", + room_version=room_version, ) def run_background_updates(self, update_name: str) -> None: @@ -77,7 +74,15 @@ def test_background_populate_rooms_creator_column(self) -> None: """ # Insert a room without the creator - room_id = self._generate_room() + # This uses room version 10, because the `POPULATE_ROOMS_CREATOR_COLUMN` + # background update assumes that the room `creator` field is available + # in the `m.room.create` event content, which was removed in room + # version 11. That assumption is safe as the background update only + # backfills rooms whose `creator` column is unset, which can only be + # rooms created before Synapse started populating the column at room + # creation time (Synapse 1.43, 2021), all of which predate room version + # 11 (2023). + room_id = self._generate_room(room_version="10") self.get_success( self.store.db_pool.simple_update( table="rooms", From f08e3cd70d39332e6429bc773300c1aa7af0933b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Thu, 16 Jul 2026 07:52:18 +0800 Subject: [PATCH 13/14] Don't use hardcoded default room version in RoomBackgroundUpdateStoreTestCase --- tests/storage/databases/main/test_room.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 6feb2f595b2..98327e93694 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -20,6 +20,7 @@ # import json +from typing import Optional from twisted.internet.testing import MemoryReactor @@ -45,7 +46,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.user_id = self.register_user("foo", "pass") self.token = self.login("foo", "pass") - def _generate_room(self, room_version: str = "11") -> str: + def _generate_room(self, room_version: Optional[str] = None) -> str: """Create a room and return the room ID.""" return self.helper.create_room_as( self.user_id, From f63c8d77a103e1e2b50214c3180c99b2fa472dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Thu, 16 Jul 2026 07:52:55 +0800 Subject: [PATCH 14/14] Reorder explanation comments to be more near the room version override --- tests/rest/client/test_redactions.py | 4 ++-- tests/storage/databases/main/test_room.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/rest/client/test_redactions.py b/tests/rest/client/test_redactions.py index a506121538c..c8ab9577a37 100644 --- a/tests/rest/client/test_redactions.py +++ b/tests/rest/client/test_redactions.py @@ -63,11 +63,11 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Create a room self.room_id = self.helper.create_room_as( + self.mod_user_id, + tok=self.mod_access_token, # FIXME: Using room version 10 here as using later version requires # https://github.com/element-hq/synapse/pull/19782 # Remove the override when the above PR is merged. - self.mod_user_id, - tok=self.mod_access_token, room_version="10", ) diff --git a/tests/storage/databases/main/test_room.py b/tests/storage/databases/main/test_room.py index 98327e93694..ef6193da988 100644 --- a/tests/storage/databases/main/test_room.py +++ b/tests/storage/databases/main/test_room.py @@ -75,15 +75,17 @@ def test_background_populate_rooms_creator_column(self) -> None: """ # Insert a room without the creator - # This uses room version 10, because the `POPULATE_ROOMS_CREATOR_COLUMN` - # background update assumes that the room `creator` field is available - # in the `m.room.create` event content, which was removed in room - # version 11. That assumption is safe as the background update only - # backfills rooms whose `creator` column is unset, which can only be - # rooms created before Synapse started populating the column at room - # creation time (Synapse 1.43, 2021), all of which predate room version - # 11 (2023). - room_id = self._generate_room(room_version="10") + room_id = self._generate_room( + # Create the room as v10, because the `POPULATE_ROOMS_CREATOR_COLUMN` + # background update assumes that the room `creator` field is available + # in the `m.room.create` event content, which was removed in room + # version 11. That assumption is safe as the background update only + # backfills rooms whose `creator` column is unset, which can only be + # rooms created before Synapse started populating the column at room + # creation time (Synapse 1.43, 2021), all of which predate room version + # 11 (2023). + room_version="10" + ) self.get_success( self.store.db_pool.simple_update( table="rooms",