Issue Description
Stalwart 1.1.1, official Docker image, Linux x86_64; reproduced on two installations. A ContactCard/set create without uid succeeds, and the card never gets one: ContactCard/get returns no uid even when asked for it, and the stored vCard has no UID line. RFC 9553 Section 2.1.9 defines uid as mandatory, and Section 1.3.3 says a mandatory property “MUST be set for an instance of this object to be valid”. CalendarEvent/set already handles the same case: an event created without uid gets a generated one.
Expected Behavior
The server generates a uid (for example urn:uuid:...), as CalendarEvent/set does, and returns it in ContactCard/get. If it does not, it rejects the create with invalidProperties.
Actual Behavior
The create returns created, and the card stays without uid over both JMAP and CardDAV. Group membership is keyed by uid (RFC 9553 Section 2.1.6, RFC 9610 Section 3), so such a card cannot be a member of any group. A client that leaves uid to the server loses every member it adds to a contact list, and gets no error.
Reproduction Steps
One ordinary account with its default address book, curl and jq:
SRV=http://localhost:8080; [email protected]; PW=userpass
U='["urn:ietf:params:jmap:core","urn:ietf:params:jmap:contacts"]'
jmap() { curl -s -u "$USER:$PW" -H 'Content-Type: application/json' -d '{"using":'"$U"',"methodCalls":[['"$1"',"0"]]}' "$SRV/jmap/" | jq -c '.methodResponses[0][1]'; }
ACC=$(curl -s -u "$USER:$PW" "$SRV/jmap/session" | jq -r '.primaryAccounts["urn:ietf:params:jmap:contacts"]')
BOOK=$(jmap '"AddressBook/get",{"accountId":"'"$ACC"'"}' | jq -r '.list[0].id')
create() { # $1 = creation id, $2 = extra properties
jmap '"ContactCard/set",{"accountId":"'"$ACC"'","create":{"'"$1"'":{"@type":"Card","version":"1.0",
"addressBookIds":{"'"$BOOK"'":true},"name":{"full":"'"$1"'"}'"$2"'}}}' | jq -r '.created["'"$1"'"].id // tojson'
}
A=$(create nouid ''); B=$(create withuid ',"uid":"urn:uuid:7a3c1d52-0d0e-4f4e-9a52-2b1c5e0f6a11"')
jmap '"ContactCard/get",{"accountId":"'"$ACC"'","ids":["'"$A"'","'"$B"'"],"properties":["uid","name"]}' | jq -c '.list[]'
# the stored vCards, over CardDAV
DAV="/dav/card/$(jq -rn --arg u "$USER" '$u|@uri')/default/"
curl -s -u "$USER:$PW" -X PROPFIND -H 'Depth: 1' "$SRV$DAV" | grep -o "<[a-zA-Z:]*href>[^<]*\.vcf\|<[a-zA-Z:]*href>$DAV[^<]\+" | sed 's/<[^>]*>//' | while read -r h; do
curl -s -u "$USER:$PW" "$SRV$h" | tr -d '\r' | grep -E '^(FN|UID):' | paste -sd' '
done | sort
Output:
{"name":{"full":"nouid"},"id":"b"}
{"name":{"full":"withuid"},"uid":"urn:uuid:7a3c1d52-0d0e-4f4e-9a52-2b1c5e0f6a11","id":"c"}
FN:nouid
FN:withuid UID:urn:uuid:7a3c1d52-0d0e-4f4e-9a52-2b1c5e0f6a11
Relevant Log Output
Trace level, create and read-back of the nouid card (client IP and auth header removed). No WARN or ERROR is logged:
DEBUG JMAP method call (jmap.method-call) command = "ContactCard/set", accountId = 293, elapsed = 6ms
TRACE HTTP response body (http.response-body) contents = "{\"methodResponses\":[[\"ContactCard/set\",{\"accountId\":\"jf\",\"oldState\":\"sae\",\"newState\":\"sai\",\"created\":{\"nouid\":{\"id\":\"b\"}}},\"0\"]],\"sessionState\":\"5c9c6af\"}"
TRACE HTTP response body (http.response-body) contents = "{\"methodResponses\":[[\"ContactCard/get\",{\"accountId\":\"jf\",\"state\":\"sam\",\"list\":[{\"name\":{\"full\":\"nouid\"},\"id\":\"b\"},{\"name\":{\"full\":\"withuid\"},\"uid\":\"urn:uuid:7a3c1d52-0d0e-4f4e-9a52-2b1c5e0f6a11\",\"id\":\"c\"}],\"notFound\":[]},\"0\"]],\"sessionState\":\"5c9c6af\"}"
Stalwart Version
v1.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
Likely cause: the create path in crates/jmap/src/contact/set.rs converts the JSContact card to a vCard and passes card.uid() to assert_is_unique_uid, which checks only if let Some(uid). Nothing fills in a missing uid. The create path in crates/jmap/src/calendar_event/set.rs does (// Generate a UID when the client omitted one, generate_uid()); the same step in the contact create path would fix this.
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