Issue Description
Custom keywords keep the case they were written with. The same keyword in upper and lower case ends up as two different keywords on one message, hasKeyword matches only the exact case, and JMAP returns mixed-case keywords. IMAP clients that use capitalised flags therefore create “duplicate” labels for JMAP clients, and removing a label by its lowercase name leaves the capitalised one behind.
Expected Behavior
RFC 8621, section 4.1.1: “For compatibility with IMAP, a keyword is a case-insensitive string … Because JSON is case sensitive, servers MUST return keywords in lowercase.”
So Pm.Remind.T0900 and pm.remind.t0900 are the same keyword, it is returned as pm.remind.t0900, and hasKeyword matches it in any case.
Actual Behavior
- Import a message with
"keywords": {"Pm.Remind.T0900": true}:
["Email/import", {"accountId": "c", "emails": {"i": {"blobId": "...", "mailboxIds": {"a": true},
"keywords": {"Pm.Remind.T0900": true}}}}, "i"]
- Query and read it:
| Request | Result |
|---|---|
Email/query {"hasKeyword": "pm.remind.t0900"} |
not found |
Email/query {"hasKeyword": "Pm.Remind.T0900"} |
found |
Email/get keywords |
{"Pm.Remind.T0900": true} |
- Add the lowercase form:
curl -s -u "[email protected]:$PASS1" -H 'Content-Type: application/json' https://mail.example.com/jmap/ -d '{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["Email/set", {"accountId": "c", "update": {"qiaaaaec": {"keywords/pm.remind.t0900": true}}}, "u"],
["Email/get", {"accountId": "c", "ids": ["qiaaaaec"], "properties": ["keywords"]}, "g"]]}'
{"methodResponses": [
["Email/set", {"accountId": "c", "oldState": "srqca", "newState": "sruca", "updated": {"qiaaaaec": null}}, "u"],
["Email/get", {"accountId": "c", "state": "sruca", "list": [{"keywords": {"pm.remind.t0900": true,
"Pm.Remind.T0900": true}, "id": "qiaaaaec"}], "notFound": []}, "g"]]}
Two keywords on one message where the RFC expects one.
Reproduction Steps
The exact requests and responses are under Actual Behavior.
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
Where it seems to come from:
crates/types/src/keyword.rs: Keyword::parse(), from_other() and from_boxed_other() keep Keyword::Other as given. Lowercasing Other values there (and treating existing mixed-case stored values as equal on read) would follow the RFC. Two smaller related points in the same file:
- the system keywords
$MailFlagBit0..2serialize in mixed case, which is also returned to JMAP clients; MAX_LENGTHis 128, while RFC 8621 allows 1-255 characters.
Stalwart v0.16.27, Docker image stalwartlabs/stalwart:v0.16-alpine, default setup from the bootstrap wizard.
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