Skip to content

Use sender instead of user_id for any stripped state event usages#1425

Closed
MadLittleMods wants to merge 1 commit into
developfrom
madlittlemods/remove-flawed-msc4311-partial-implementation
Closed

Use sender instead of user_id for any stripped state event usages#1425
MadLittleMods wants to merge 1 commit into
developfrom
madlittlemods/remove-flawed-msc4311-partial-implementation

Conversation

@MadLittleMods

Copy link
Copy Markdown
Contributor

Use sender instead of user_id for any stripped state event usages

Spawning from element-hq/synapse#19723 (where these tests started to fail) which ensures we actually use stripped state everywhere. Stripped state only has content, sender, state_key, type available. Previously, this relied on the full PDU being available which meant access touser_id as well.

user_id is a deprecated field from Synapse that isn't in the spec.

Dev notes

Example failure:
Error: FAILURE: #219: Can invite unbound 3pid over federation with no ops into a private room
Logs
  # Started: 2026-05-26 20:15:54.169
  # Ended: 2026-05-26 20:15:55.904
  # No inviter member invite state at tests/30rooms/12thirdpartyinvite.pl line 229.
  # 0.029646: Registered new user @anon-20260526_201439-154:127.0.0.1:8838
  # 0.052488: Registered new user @anon-20260526_201439-152:127.0.0.1:8800
  # 0.053313: Registered new user @anon-20260526_201439-153:127.0.0.1:8800
  # 0.439184: room_id=!KRaggKHbkwunOCEjIy:127.0.0.1:8800
  # 0.545050: Invited user @anon-20260526_201439-153:127.0.0.1:8800 to !KRaggKHbkwunOCEjIy:127.0.0.1:8800
  # {}
  # 0.664036: User @anon-20260526_201439-153:127.0.0.1:8800 joined room
  # { room_id => "!KRaggKHbkwunOCEjIy:127.0.0.1:8800" }
  # 0.714240: Created room_id=!KRaggKHbkwunOCEjIy:127.0.0.1:8800
  # 1.159396: sent 3pid invite for lemurs@monkeyworld.org to SyTest::Identity::Server=HASH(0x55b492174fc8)
  # 1.730745: Invite
  # {
  #   invite_state => {
  #     events => [
  #       {
  #         content   => {
  #                        creator => "\@anon-20260526_201439-152:127.0.0.1:8800",
  #                        room_version => 10,
  #                      },
  #         sender    => "\@anon-20260526_201439-152:127.0.0.1:8800",
  #         state_key => "",
  #         type      => "m.room.create",
  #       },
  #       {
  #         content   => { join_rule => "invite" },
  #         sender    => "\@anon-20260526_201439-152:127.0.0.1:8800",
  #         state_key => "",
  #         type      => "m.room.join_rules",
  #       },
  #       {
  #         content   => { alias => "#test-20260526_201439-23:127.0.0.1:8800" },
  #         sender    => "\@anon-20260526_201439-152:127.0.0.1:8800",
  #         state_key => "",
  #         type      => "m.room.canonical_alias",
  #       },
  #       {
  #         content   => {
  #                        membership => "invite",
  #                        third_party_invite => {
  #                          display_name => "Bob",
  #                          signed => {
  #                            mxid => "\@anon-20260526_201439-154:127.0.0.1:8838",
  #                            signatures => {
  #                              "localhost:45425" => {
  #                                "ed25519:0" => "nYMBeK9UPutCo2CxT7JQat8pwbmmixGJT/xVTqsRZVArP7YVwWv0XRogUYA82pSqoZyw9eLtQ6dvmT4ORuAqAg",
  #                              },
  #                            },
  #                            token => 3,
  #                          },
  #                        },
  #                      },
  #         sender    => "\@anon-20260526_201439-153:127.0.0.1:8800",
  #         state_key => "\@anon-20260526_201439-154:127.0.0.1:8838",
  #         type      => "m.room.member",
  #       },
  #     ],
  #   },
  # }

Testing:

docker run --rm -it \
    -v ~/Documents/github/element/synapse:/src:ro \
    -v ~/Documents/github/element/sytest/logs\:/logs \
    -v ~/Documents/github/element/sytest:/sytest:ro \
    matrixdotorg/sytest-synapse:bookworm \
    tests/30rooms/12thirdpartyinvite.pl

Generic (from docs):

docker run --rm -it -v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs \
    -v /path/to/code/sytest\:/sytest:ro matrixdotorg/sytest-synapse:bookworm

anoadragon453

This comment was marked as outdated.


my %members = map {
$_->{state_key} => $_
$_->{sender} => $_

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PR description talks about updating user_id -> sender but the diff shows state_key -> sender?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ugh, totally!

This is my mistake. My original attempt did do user_id -> sender changes (#1424) but I also made too many changes and caused other errors (all manual changes). I then started over and had an LLM do a cycle of (change -> test) to find the minimum changes and it ended up here. I didn't notice it wasn't a user_id -> sender change and kept the same reasoning. Sorry for the slopped on experience.

All of that is a red herring though and it's just my naive-perl eyes spotting user_id when all of that is actually fine and the actual problem is we're dropping the inviter's membership as the error actually says. Most likely caused by this review point.

This is all unspecced behavior but is something Synapse has been doing forever and tested here so probably have to keep it going.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Closing as no change to Sytest is probably necessary ⏩

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