Skip to content

TestRoomCreationReportsEventsToMyself tests unspecified behaviour #901

Open

Description

@timedoutuk

// sytest: Setting state twice is idempotent
t.Run("Setting state twice is idempotent", func(t *testing.T) {
t.Parallel()
stateEvent := b.Event{
Type: "a.test.state.type",
StateKey: b.Ptr(""),
Content: map[string]interface{}{
"a_key": "a_value",
},
}
firstID := alice.SendEventSynced(t, roomID, stateEvent)
secondID := alice.SendEventSynced(t, roomID, stateEvent)
if firstID != secondID {
t.Fatalf("Both Event IDs from supposedly-idempotent state-setting differ, %s != %s", firstID, secondID)
}
})

This behaviour is not written anywhere in the specification and is technically incorrect behaviour considering there is no transaction ID for setting state (which removes the idempotency guarantee)

Activity

  1. timedoutuk commented on Jul 15, 2026

    @timedoutuk
    ContributorAuthor

    Joining room twice is idempotent suffers this same problem:

    // sytest: Joining room twice is idempotent
    t.Run("Joining room twice is idempotent", func(t *testing.T) {
    t.Parallel()
    roomID := bob.MustCreateRoom(t, map[string]interface{}{
    "visibility": "public",
    "preset": "public_chat",
    })
    alice.MustJoinRoom(t, roomID, nil)
    alice.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(alice.UserID, roomID))
    firstID := *getEventIdForState(t, alice, roomID, "m.room.member", alice.UserID)
    alice.MustJoinRoom(t, roomID, nil)
    // Unfortunately there is no way to definitively wait
    // for a 'potentially false second join event' without
    // also failing the test on timeout, with the current APIs.
    //
    // So we take a conservative estimate of a 5-second sleep delay
    // before we check on the server again.
    time.Sleep(5 * time.Second)
    secondID := *getEventIdForState(t, alice, roomID, "m.room.member", alice.UserID)
    if firstID != secondID {
    t.Fatalf("Both Event IDs from supposedly-idempotent room joins differ, %s != %s", firstID, secondID)
    }

    Neither /_matrix/client/v3/join/{roomIdOrAlias} nor /_matrix/client/v3/rooms/{roomId}/join state that multiple calls have to be idempotent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions