V1.0.0: A yearless BDAY that Stalwart serves as vCard 3.0 (–03-15) loses its day when it is uploaded again, and is then written as –3

Issue Description

On v1.0.0, with AddressBook.vCardVersion set to v3, Stalwart serves a birthday without a year as BDAY:–03-15. When a client uploads that same value in a vCard 3.0 card, Stalwart stores only the month and drops the day. The PUT returns 201 and nothing is logged. The month-only date is then written as BDAY:–3 in both 3.0 and 4.0. So a 3.0 client that saves back a card it got from Stalwart (for example after the user edits another field) silently loses the day of a yearless birthday. We set v3 because iPhone Contacts never asks for a version and reads 4.0 as Latin-1 (t/405).

Expected Behavior

Stalwart reads back the value it writes: BDAY:–03-15 in a 3.0 card is stored as month 3, day 15 and served again as --03-15 (3.0) or --0315 (4.0). A month-only date is written zero-padded, --03, as in the RFC 6350 §4.3.1 examples.

Actual Behavior

Uploaded
Served as 3.0
Served as 4.0
3.0, BDAY:–03-15
BDAY:–3
BDAY:–3
3.0, BDAY:–0315
BDAY:–03-15
BDAY:–0315
4.0, BDAY:–0315
BDAY:–03-15
BDAY:–0315
3.0, BDAY;X-APPLE-OMIT-YEAR=1604:1604-03-15
unchanged
…:16040315
The first row is the problem: its input is exactly what rows 2 and 3 serve as 3.0. Apple’s own form in row 4 round-trips correctly (fixed with t/2000).
In the source at v1.0.0: push_legacy_vcard writes a month and day without a year as --MM-DD (crates/calcard/src/vcard/writer.rs:465-470). On upload, parse_vcard_date_legacy (vcard/parser.rs:749) needs a full year-month-day, so --03-15 falls back to parse_vcard_date (lines 868-877). That function reads 03 as the month, then reads the day with parse_small_digits(…, false), which stops at the - before 15. The rest is ignored and the date is not null, so it counts as a successful parse. The month-only arm (None, Some(month), None) in both writers uses push_u64 instead of push_2_digits (writer.rs:369-371 and 478-480), hence --3.
A possible fix: accept the - before the day in parse_vcard_date, and use push_2_digits in both month-only arms. Optionally, write a yearless 3.0 date in Apple’s X-APPLE-OMIT-YEAR=1604 form, which Stalwart already round-trips, since RFC 2426 has no truncated dates.

Reproduction Steps

Set AddressBook.vCardVersion to v3 and restart.
PUT to /dav/card//default/probe.vcf:
BEGIN:VCARD
VERSION:3.0
UID:probe
FN:Probe
N:Probe;;;;
BDAY:–03-15
END:VCARD
GET the card with no Accept header → BDAY:–3.
GET it with Accept: text/vcard; version=4.0 → BDAY:–3.
Repeat with BDAY:–0315 instead. GET with no Accept header returns BDAY:–03-15, which is the value from step 2.

Stalwart Version

v1.x

Installation Method

Docker

Database Backend

RocksDB

Blob Storage

RocksDB

Search Engine

Internal

Directory Backend

OIDC

Additional Context

Found with curl against v1.0.0; the only relevant setting is AddressBook.vCardVersion = v3. The configuration is applied as JMAP objects with stalwart-cli apply. We have not checked yet whether iOS Contacts sends --03-15 back unchanged.

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

Your source reading matches what I found in the current tree. I haven’t run the reproduction.

In crates/calcard/src/vcard/writer.rs, both month-only arms (None, Some(month), None) write the month with buf.push_u64(month.into()). That is at lines 369-371 and 478-480. It explains why --03 comes out as --3.

The parser side is also where you said. PartialDateTime::parse_vcard_date_legacy is at vcard/parser.rs:749. I only read its signature, not the fallback into parse_vcard_date. I haven’t confirmed how that function handles the - before the day, so the “stops at the -” part of your diagnosis is still unchecked by me.

The docs don’t cover this, so I can’t give a documented answer or workaround. This looks like a real round-trip bug, and the two fixes you suggest are the obvious candidates. They are accepting --MM-DD in the fallback parser, and zero-padding the month-only output with push_2_digits. A human will follow up here.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

The day was lost in the date parser: parse_vcard_date read the month of --03-15, stopped at the - before the day, and still treated the result as a valid date, so a 3.0 client saving back what we served lost the day without any error. The month-only writer arms used an unpadded number, which is where --3 came from.

Both are fixed: --MM-DD is now read as month and day in 3.0 and 4.0 cards, and a month-only date is written as --03. I kept --MM-DD as the 3.0 output and didn’t switch to the X-APPLE-OMIT-YEAR=1604 form, because other 3.0 clients would then show the year 1604. The fix ships in next week’s release.

Cards that already lost the day were stored as month-only, so those birthdays need the day entered again once you’re on the new version.