Skip to content

"Encryption is already enabled!" error during room creation #864

@RxmTaco

Description

@RxmTaco

Creating a new room with encryption enabled on a homeserver that has encryption enabled by default throws Encryption is already enabled!.

To Reproduce
Steps to reproduce the behavior:

  1. Set encryption_enabled_by_default_for_room_type: invite on homeserver configuration
  2. Create private space and click on create room
  3. Select Text Chat
  4. Make sure slider for Enable Encryption is checked
  5. Click Create Room! button
  6. The following Error dialog should pop up with a message Encryption is already enabled!
Image

Expected behavior
Room gets created.

Additional context
During room creation, the homeserver can return a room that has encryption already enabled depending on the server's configuration, but this does not get taken into account during room creation in matrix_client.dart. After room creation the enableE2EE flag gets checked, which directly corresponds to the UI slider value, and room encryption is applied depending on the flag.

if (args.enableE2EE!) {
await matrixRoom.enableEncryption();
}

If the newly created room has encryption already enabled, Room.enableEncryption throws Encryption is already enabled!.

Fix:
Add a guard to the if statement that checks the Room.encrypted flag before trying to apply encryption.

Since the encryption step only depends on the enableE2EE flag, a workaround is to just uncheck the Enable Encryption slider in room creation, which would still create an encrypted room if the homeserver has applied encryption by default.

As a feature, it would be nice if the user gets notified if the encryption was enabled by default, since the room can be encrypted even if the user has unchecked the Enable Encryption switch during room creation.

Console output

Encryption is already enabled! (Room.enableEncryption)
#0      Room.enableEncryption (package:matrix/src/room.dart:2551:20)
#1      MatrixClient.createRoom (package:commet/client/matrix/matrix_client.dart:517:24)
<asynchronous suspension>
#2      GetOrCreateRoom.show.<anonymous closure> (package:commet/ui/pages/get_or_create_room/get_or_create_room.dart:90:35)
<asynchronous suspension>
#3      _GetOrCreateRoomState.onNextButtonPressed (package:commet/ui/pages/get_or_create_room/get_or_create_room.dart:534:22)
<asynchronous suspension>
Device Information

Device
Platform: linux
Version: v0.4.1
Git Hash: c2ee370d18c822673b24b6579842a01b971b1584
Detail: debian
Build Timestamp: 1772620801855 (March 4, 2026)

System Info
Name: CachyOS Linux

Display Server: wayland
Desktop Environment: wayland

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