Issue Description
Changing the Account type of an existing principal from User to Group (or vice versa) — via the web-admin, the management JMAP API, or stalwart-cli — panics a worker thread and the connection is dropped without an HTTP response. The server process itself keeps running (only the request task dies).
Expected Behavior
A client request must never panic a worker thread or drop the connection — validate_account should return a result instead of hitting unreachable!(). Concretely, one of:
If account types are intentionally immutable (which the current match arms imply): the API should reject the update with a clean JMAP SetError — e.g. notUpdated with type invalidProperties on @type and a message like “the account type cannot be changed after creation”. The web-admin should then display that message instead of NetworkError when attempting to fetch resource, and ideally disable/hide the Account type selector when editing an existing account (it’s only meaningful at creation).
If converting an account’s type is meant to be supported: implement the missing match arms in validate_account so a User → Group (and Group → User) transition is handled — retaining the existing mailbox/data and adjusting the type-specific fields (credentials, roles, members) accordingly.
In both cases the _ => unreachable!() arm should be replaced with a proper, non-panicking error path, so malformed or unsupported updates are reported to the client rather than terminating the connection.
Actual Behavior
Panic
thread ‘tokio-rt-worker’ panicked at crates/jmap/src/registry/mapping/principal.rs:248:14:
internal error: entered unreachable code
Reproduction Steps
Web-admin: pick a User account (empty mailbox is fine) → Edit → Account type → Group account → Save → NetworkError when attempting to fetch resource.
Equivalent management API call:
{
“using”: [“urn:ietf:params:jmap:core”, “urn:stalwart:jmap”],
“methodCalls”: [
[“Account/set”, { “accountId”: “”, “update”: { “”: { “@type”: “Group” } } }, “c0”]
]
}
→ worker panics (above), connection dropped, no methodResponses.
Also via stalwart-cli … account update --field @type=Group.
Relevant Log Output
docker logs stalwart --since 2m 2>&1
thread ‘tokio-rt-worker’ (7) panicked at crates/jmap/src/registry/mapping/principal.rs:248:14:
internal error: entered unreachable code
thread ‘tokio-rt-worker’ (7) panicked at crates/jmap/src/registry/mapping/principal.rs:248:14:
internal error: entered unreachable code
thread ‘tokio-rt-worker’ (7) panicked at crates/jmap/src/registry/mapping/principal.rs:248:14:
internal error: entered unreachable code
thread ‘tokio-rt-worker’ (7) panicked at crates/jmap/src/registry/mapping/principal.rs:248:14:
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on