Skip to content

fix: improve CalDAV sync robustness with namespace URI and error handling - #1874

Merged
alextselegidis merged 1 commit into
alextselegidis:developfrom
AusDavo:fix/caldav-sync-robustness
May 6, 2026
Merged

fix: improve CalDAV sync robustness with namespace URI and error handling#1874
alextselegidis merged 1 commit into
alextselegidis:developfrom
AusDavo:fix/caldav-sync-robustness

Conversation

@AusDavo

@AusDavo AusDavo commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Two fixes to improve CalDAV sync reliability:

  • Use namespace URI instead of prefix for XML parsingparse_xml_events() previously tried a hardcoded list of prefixes ('cal', 'C', 'c') to find calendar-data elements. XML namespace prefixes are arbitrary — only the URI is guaranteed. This replaces the prefix-guessing with ->children('urn:ietf:params:xml:ns:caldav') which works with all compliant CalDAV servers regardless of their chosen prefix. Improves on the approach in Can't import caldav events that were created with radicale #1840.

  • Wrap individual event imports in try/catch — In Caldav::sync(), a single event failing validation (e.g. the minimum duration check in Unavailabilities_model) would abort the entire sync. Now each event is processed independently — failures are logged and the remaining events continue syncing.

Context

Discovered while syncing with Fastmail's CalDAV server, which uses xmlns:c="urn:ietf:params:xml:ns:caldav". The 'c' prefix was added in #1840 but the underlying issue remains for any server using a prefix not in the hardcoded list. The namespace URI approach is the correct solution per the XML specification.

The error handling gap was discovered when a recurring calendar event expanded to a sub-5-minute instance, triggering EVENT_MINIMUM_DURATION validation and crashing the sync for all remaining events.

Test plan

  • CalDAV sync with Fastmail (prefix c)
  • CalDAV sync with other providers (Radicale uses C, some use cal)
  • Sync a calendar containing events shorter than EVENT_MINIMUM_DURATION — they should be skipped with a log entry, not crash the sync
  • Verify skipped events are logged in storage/logs/

🤖 Generated with Claude Code

…ling

Use the CalDAV namespace URI ('urn:ietf:params:xml:ns:caldav') instead of
guessing the XML prefix when parsing calendar-data elements. The previous
approach tried 'cal', 'C', and 'c' but would fail for any server using a
different prefix. XML namespace prefixes are arbitrary — only the URI is
guaranteed, so matching by URI works with all compliant CalDAV servers.

Wrap individual event imports in a try/catch so that a single problematic
event (e.g. one failing the minimum duration validation) no longer aborts
the entire sync. Skipped events are logged for troubleshooting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alextselegidis
alextselegidis merged commit 216965b into alextselegidis:develop May 6, 2026
@alextselegidis

Copy link
Copy Markdown
Owner

Thanks for providing this fix.

--

Alex Tselegidis, Easy!Appointments Creator

Go Premium: Custom Dev, Hosting, Support, Rebrand & more →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants