Skip to content

feat: support for room v11#858

Open
FrenchGithubUser wants to merge 1 commit intomatrix-org:mainfrom
famedly:tt/room-v11-default-upstreaming
Open

feat: support for room v11#858
FrenchGithubUser wants to merge 1 commit intomatrix-org:mainfrom
famedly:tt/room-v11-default-upstreaming

Conversation

@FrenchGithubUser
Copy link
Copy Markdown

@FrenchGithubUser FrenchGithubUser commented Apr 16, 2026

  • Rooms v11 and above don't have the creator field anymore during room creation, which broke the tests.
  • Synapse changed the way it counted the state_key length in events (from codepoints to bytes) at room v11, which broke the tests.

This PR fixes those issues, making complement work with room v11 as default.

Related to element-hq/synapse#18680

@FrenchGithubUser FrenchGithubUser requested review from a team as code owners April 16, 2026 13:32
Copy link
Copy Markdown
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Comment thread federation/server_room.go Outdated
Comment on lines +346 to +350
// The creator field was removed in room version 11 (MSC4239).
n, err := strconv.Atoi(string(roomVer))
if err != nil || n < 11 {
content["creator"] = creator
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like something that should be handled by this kind of thing:

iRoomVer := gomatrixserverlib.MustGetRoomVersion(roomVer)
if iRoomVer.CreatorInCreateEvent() {

CreatorInCreateEvent doesn't exist yet but aligns with the other things we have there like DomainlessRoomIDs and PrivilegedCreators

See #840 for how v12 rooms were added

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good idea! done, and also added a change there matrix-org/gomatrixserverlib#465

Comment thread federation/server_room.go
Signed-off-by: Thomas Traineau t.traineau@famedly.com
@FrenchGithubUser FrenchGithubUser force-pushed the tt/room-v11-default-upstreaming branch from 6af47bf to 1feb361 Compare April 17, 2026 12:20
Comment on lines +44 to +47
// The creator field was removed in room version 11 (MSC4239).
if defaultVerN < 11 {
must.Equal(t, ev.Get("content").Get("creator").Str, alice.UserID, "wrong content.creator")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can use the same CreatorInCreateEvent check in this other spot as well

Comment on lines 500 to +516
ver := alice.GetDefaultRoomVersion(t)
// This test crafts a "bad" event which state_key is 280 bytes but only 70
// codepoints.
//
// Room version 11 in Synapse switched from using codepoints to using
// bytes. Which means the 280-byte state_key would be rejected immediately.
// Use room version 10 in that case so the codepoint-based limit is in effect.
//
// Since upgrading a room (for example from v10 to v11) won't carry the event
// (a new room is created), we don't have to worry about v10 room events in a v11
// room.
//
// So this test is essentially skipped for any default room v11 or higher.
verNum, _ := strconv.Atoi(string(ver))
if verNum >= 11 {
ver = gomatrixserverlib.RoomVersion("10")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like yet another case that we should handle with a new assert iRoomVer.StrictEventByteLimits() check

You can see how we do this in Synapse synapse/event_auth.py#L487-L499

Comment on lines 500 to +516
ver := alice.GetDefaultRoomVersion(t)
// This test crafts a "bad" event which state_key is 280 bytes but only 70
// codepoints.
//
// Room version 11 in Synapse switched from using codepoints to using
// bytes. Which means the 280-byte state_key would be rejected immediately.
// Use room version 10 in that case so the codepoint-based limit is in effect.
//
// Since upgrading a room (for example from v10 to v11) won't carry the event
// (a new room is created), we don't have to worry about v10 room events in a v11
// room.
//
// So this test is essentially skipped for any default room v11 or higher.
verNum, _ := strconv.Atoi(string(ver))
if verNum >= 11 {
ver = gomatrixserverlib.RoomVersion("10")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this test would be better if we just always used room version 10 🤔 . The current setup is only better if we're trying to support homeservers that don't support room version 10 yet (do we care about that?)

Suggested change
ver := alice.GetDefaultRoomVersion(t)
// This test crafts a "bad" event which state_key is 280 bytes but only 70
// codepoints.
//
// Room version 11 in Synapse switched from using codepoints to using
// bytes. Which means the 280-byte state_key would be rejected immediately.
// Use room version 10 in that case so the codepoint-based limit is in effect.
//
// Since upgrading a room (for example from v10 to v11) won't carry the event
// (a new room is created), we don't have to worry about v10 room events in a v11
// room.
//
// So this test is essentially skipped for any default room v11 or higher.
verNum, _ := strconv.Atoi(string(ver))
if verNum >= 11 {
ver = gomatrixserverlib.RoomVersion("10")
}
// This test crafts a "bad" event which state_key is 280 bytes but only 70
// codepoints.
//
// Room version 11 in Synapse switched from using codepoints to using
// bytes. Which means the 280-byte state_key would be rejected immediately.
// Use room version 10 in that case so the codepoint-based limit is in effect.
//
// Since upgrading a room (for example from v10 to v11) won't carry the event
// (a new room is created), we don't have to worry about v10 room events in a v11
// room.
//
// So this test is essentially skipped for any default room v11 or higher.
ver = gomatrixserverlib.RoomVersion("10")

Comment thread federation/server_room.go
// hashes will not be the same.
"complement_entropy": util.RandomString(18),
}
if gomatrixserverlib.MustGetRoomVersion(gomatrixserverlib.RoomVersion(roomVer)).CreatorInCreateEvent() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Wait for matrix-org/gomatrixserverlib#465 to merge and update the gomatrixserverlib version in this PR

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.

3 participants