-
Notifications
You must be signed in to change notification settings - Fork 13.2k
fix(caldav): default calendar not written on booking #28934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Harshithk951
wants to merge
3
commits into
calcom:main
Choose a base branch
from
Harshithk951:fix/caldav-default-calendar-booking-clean-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−16
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🌐 Web query:
Does the CalDAV/WebDAV PROPFIND response for calendar-home-set guarantee the primary/default calendar is listed first? Is there a standard property (e.g., CALDAV:schedule-default-calendar-URL) to identify the default calendar?💡 Result:
No, the CalDAV/WebDAV PROPFIND response for calendar-home-set does not guarantee that the primary/default calendar is listed first. RFC 4791 defines CALDAV:calendar-home-set as containing zero or more DAV:href elements identifying collections with the principal's calendars, with no specification on order (RFC 4791 Section 6.2.1; sources 1,11). Implementations may vary in ordering, and clients cannot rely on position (e.g., GitHub issue on Stalwart notes clients like Apple do not consistently pick first; source 5). Yes, there is a standard property: CALDAV:schedule-default-calendar-URL (urn:ietf:params:xml:ns:caldav), defined in RFC 6638 Section 9.2. It MAY be defined on the scheduling Inbox collection (discovered via CALDAV:schedule-inbox-URL on the principal) and, if present with a DAV:href, points to the default calendar where new scheduling objects are created (sources 6,7,9,10). Servers SHOULD use this for new scheduling objects (RFC 6638 Section 4.3). Some implementations expose it on the principal too, but standard location is the inbox (source 9).
Citations:
calendar-home-setandaddressbook-home-setstalwartlabs/stalwart#1796CALDAV:schedule-default-calendar-URLis set on the principal instead of the scheduling inbox nextcloud/server#57883🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 1332
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 664
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 85
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 3255
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 2295
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 40
🏁 Script executed:
Repository: calcom/cal.diy
Length of output: 261
Use
ErrorWithCodeinstead ofnew Error, and prefer the standardCALDAV:schedule-default-calendar-URLproperty for identifying the primary calendar.The fix correctly avoids writing to all discovered collections, but has two issues:
Error type: Line 471 throws
new Error(...), violating the guideline to useErrorWithCodein non-tRPC lib files. Refactor toErrorWithCodewith an appropriate error code.Calendar selection fallback:
calendars.slice(0, 1)assumes the server returns the primary calendar first, but RFC 4791 (CalDAV) does not guarantee PROPFIND response order. Per RFC 6638 Section 9.2, servers expose the default calendar via theCALDAV:schedule-default-calendar-URLproperty (typically on the scheduling inbox collection discovered viaCALDAV:schedule-inbox-URL). Iftsdavsurfaces this property, prefer it over positional fallback. If not available, at least log which calendar URL was chosen when falling back to the first one, so misrouted writes are debuggable.Note: The behavior change is intentional — previously an unmatched
externalIdproduced an empty list andPromise.all([])resolved silently; now it throws and triggers the compensating-update pattern (perRegularBookingService), potentially flipping a booking toPENDING. More correct, but user-visible.🤖 Prompt for AI Agents