CalDAV: Recurrence override VEVENT missing mandatory DTSTART when JMAP recurrenceOverride has no start property

Issue Description

Hi all,

i hope AI supported bug reports are not frowned upon. But this caused already multiple times issues on my productive setup.

Bug Report: CalDAV Recurrence Override VEVENT Missing Mandatory DTSTART

Summary

When an iCalendar .ics resource is requested over CalDAV for a recurring event that contains recurrence overrides, Stalwart serializes the override as a secondary BEGIN:VEVENT ... END:VEVENT block containing RECURRENCE-ID but completely missing DTSTART.

This violates RFC 5545 §3.6.1 and causes strict CalDAV clients (such as DAVx5 on Android) to fail parsing with ResourceMappingException: Missing DTSTART in VEVENT, aborting the entire calendar synchronization.


Environment

  • Stalwart Version: v0.16.27 (Docker image stalwartlabs/stalwart:v0.16-alpine)
  • Protocol: CalDAV (/dav/cal/...)
  • Client: DAVx5 (Android, at.bitfire.synctools)

Steps to Reproduce

  1. Create a recurring event on Stalwart (e.g., weekly on Mondays at 09:00 UTC).
  2. Modify a single instance of the event (or receive an attendee RSVP / update from an external mail client like Outlook or Apple Calendar) where:
    • The instance start time is not changed.
    • Another property is changed (e.g., title, description, or attendee participation status).
  3. In Stalwart’s internal JMAP representation, this produces a recurrenceOverrides map where the partial object legitimately omits start (per RFC 8984 §4.1.3, since start defaults to the recurrence occurrence timestamp).
  4. Fetch the .ics resource via CalDAV:
    GET /dav/cal/<user>/default/<event-uid>.ics HTTP/1.1
    Host: mail.example.com
    Authorization: Basic ...
    

Observed Behavior

Stalwart returns an iCalendar object where the overridden instance VEVENT lacks DTSTART:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Stalwart Labs//Stalwart Mail Server//EN
BEGIN:VEVENT
UID:2117ae7d-9f5f-45a7-b4ea-3bac225c716b
DTSTART:20261015T090000Z
DURATION:PT1H
RRULE:FREQ=WEEKLY;BYDAY=MO
SUMMARY:Team Sync
...
END:VEVENT
BEGIN:VEVENT
UID:2117ae7d-9f5f-45a7-b4ea-3bac225c716b
RECURRENCE-ID:20261022T090000Z
SUMMARY:Team Sync (Agenda Updated)
...
END:VEVENT
END:VCALENDAR

Notice that the secondary VEVENT with RECURRENCE-ID:20261022T090000Z does not contain a DTSTART line.


Client Impact (DAVx5 Exception Log)

DAVx5 uses bitfire synctools, which strictly validates RFC compliance. The synchronization worker crashes with:

at.bitfire.synctools.exception.ResourceMappingException: Missing DTSTART in VEVENT
	at androidx.work.OperationKt.requireDtStart(r8-map-id-...:27)
	at at.bitfire.synctools.mapping.calendar.builder.UidBuilder.build(r8-map-id-...:45)
	at at.bitfire.davdroid.sync.JtxSyncManager.processICalendar(r8-map-id-...:563)
	at androidx.glance.session.SessionWorker$doWork$2$2.invokeSuspend(r8-map-id-...:421)
	...
REMOTE RESOURCE
https://mail.example.com/dav/cal/<user>/default/2117ae7d-9f5f-45a7-b4ea-3bac225c716b.ics

Because of this exception, calendar synchronization halts completely and subsequent events are not downloaded to the mobile device.


Specification Analysis (RFC 5545 vs RFC 8984)

  1. RFC 5545 §3.6.1 (Event Component):

    “The following is REQUIRED if the component is an exception to a recurring ‘VEVENT’ calendar component: recurrence-id”

    “The following is REQUIRED if the event is not a recurrent event: dtstart”

    “The following is REQUIRED if the event is a recurrent event …: dtstart”

    In iCalendar, every VEVENT component must have a DTSTART property, including exception components with a RECURRENCE-ID.

  2. RFC 8984 §4.1.3 (JSCalendar / JMAP recurrenceOverrides):

    “The value is a PartialCalendarEvent object, which is a Map of property names from the CalendarEvent object … to the overridden value … When evaluating a recurrence override, the properties of the PartialCalendarEvent override the corresponding properties of the master CalendarEvent object.”

    In JMAP / JSCalendar, omitting start from a recurrence override is valid because it inherits the recurrence instance start time.

  3. Root Cause:
    When Stalwart’s JMAP-to-iCalendar exporter serializes recurrenceOverrides, it only generates a DTSTART property if override.start != null. When override.start is null, it fails to fall back to the recurrence instance key (RECURRENCE-ID).


Proposed Fix

In Stalwart’s iCalendar serialization logic (where recurrenceOverrides entries are turned into VEVENT components):

  1. Check if the override object contains an explicit start property.
  2. If start is null or omitted, derive DTSTART from the recurrenceOverrides key (RECURRENCE-ID).
  3. Similarly, ensure DURATION or DTEND falls back to the master event’s duration if not overridden.

Workaround

Updating the JMAP event directly via CalendarEvent/set to explicitly populate "recurrenceOverrides/<recurrenceId>/start" resolves the issue immediately and allows CalDAV clients to resume sync:

{
  "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:calendars"],
  "methodCalls": [
    [
      "CalendarEvent/set",
      {
        "accountId": "<account-id>",
        "update": {
          "<event-id>": {
            "recurrenceOverrides/<recurrence-id>/start": "<recurrence-id>",
            "recurrenceOverrides/<recurrence-id>/duration": "PT1H"
          }
        }
      },
      "c0"
    ]
  ]
}

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

Thanks for the detailed report and reproduction steps. I can confirm from the source how CalDAV GET requests are served: the calendar resource handler fetches the stored CalendarEvent, and the response body is generated directly from the archived ICalendar object via event.data.event.to_string() (no additional pass to inject a DTSTART into override components at render time). See crates/dav/src/calendar/get.rs.

Separately, the CalendarEvent/get JMAP handler (which builds synthetic recurrence-instance representations) does explicitly add a DTSTART entry derived from the expanded occurrence timestamp when expanding overrides for JMAP responses, with the RECURRENCE-ID falling back to the same timestamp if the stored override doesn’t carry one. That fallback logic lives in crates/jmap/src/calendar_event/get.rs around the Dtstart/RecurrenceId handling, but it is used for JMAP expansion/instance resolution, not for the raw .ics export used by the WebDAV GET handler, which just serializes the underlying ICalendar component tree as stored.

That is consistent with your root-cause theory: if an override VEVENT component in the stored iCalendar tree has no DTSTART of its own, the DAV GET path will emit it as-is without back-filling from the RECURRENCE-ID.

This is a server-side behavior finding rather than something documented, so I can’t point you to a docs page confirming a fix or workaround beyond what you already found (explicitly setting recurrenceOverrides/<id>/start). A staff member will need to confirm whether this is being addressed in the iCalendar export/serialization path.

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

That’s a 0.16 bug: an override is converted to iCalendar with only the properties it changes, so without start there’s nothing to put in DTSTART, and DAVx5 is right to refuse it.

v1.0.0, out this week, starts each override from the master event at that occurrence and applies the patch on top, so DTSTART and the duration are always there. Including start in the override, as you’re doing, is the workaround until then. I’d also re-save the events that already have such an override after upgrading, since what’s stored for them still lacks DTSTART.