You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): discover CalDAV principals with PROPFIND - #15811
CalDAV account discovery now uses PROPFIND to find the current-user principal. It resolves principal and calendar-home hrefs relative to response URLs. Tests cover redirects, relative hrefs, and 401 and 403 discovery responses.
Changes: CalDAV principal discovery
Layer / File(s)
Summary
Principal discovery and validation packages/backend/server/src/plugins/calendar/providers/caldav.ts, packages/backend/server/src/plugins/calendar/__tests__/caldav.spec.ts
Discovery starts with PROPFIND to /.well-known/caldav and retries the server URL for HTTP 400, 404, 405, or 501 when the URLs differ. The provider resolves principal and calendar-home hrefs against response URLs. Tests cover discovery redirects, relative hrefs, event parsing, and 401 and 403 responses.
sequenceDiagram
participant discoverAccount
participant fetchCurrentUserPrincipal
participant CalDAVServer
participant CalendarHomeLookup
discoverAccount->>fetchCurrentUserPrincipal: serverUrl
fetchCurrentUserPrincipal->>CalDAVServer: PROPFIND /.well-known/caldav
CalDAVServer-->>fetchCurrentUserPrincipal: response URL and principal href
fetchCurrentUserPrincipal->>CalDAVServer: fallback PROPFIND serverUrl for selected statuses
fetchCurrentUserPrincipal-->>discoverAccount: discovery URL and resolved principal URL
discoverAccount->>CalendarHomeLookup: principal URL
CalendarHomeLookup->>CalDAVServer: PROPFIND for calendar home
Loading
Suggested labels:app:server, test
Merge Risk: Low · up to 858f4
Some CalDAV servers redirect the well-known URL to a non-DAV page. Account linking can then fail even though the configured URL works. The core PROPFIND-based discovery fix is sound, so this is a bounded follow-up.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(server): discover CalDAV principals with PROPFIND" matches the main change. The provider now starts principal discovery with a PROPFIND at the preset server URL and derives the account …
Linked Issues check
Linked issue #15482 is the only active direct target. Its coding requirement: after following redirects, do not assume a 200 response is a valid DAV discovery target. Validate the resolved URL, or iss…
Out of Scope Changes check
The whole-PR diff (mergeBase 4ac1636 to head 858f45d) touches two files. caldav.ts changes are confined to the CalDAV discovery path. These are: removal of resolveDiscoveryUrl, folding discovery URL…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check
Explanation
The title "fix(server): discover CalDAV principals with PROPFIND" matches the main change. The provider now starts principal discovery with a PROPFIND at the preset server URL and derives the account ID from the principal URL. The linked issue asks for the same behavior, so the title names the core fix. It does not mention the redirect handling or the 401/403 error propagation, but it does not need to cover every detail.
Full details: Linked Issues check
Explanation
Linked issue #15482 is the only active direct target. Its coding requirement: after following redirects, do not assume a 200 response is a valid DAV discovery target. Validate the resolved URL, or issue a PROPFIND for current-user-principal per RFC 6764. The head implements the second option in caldav.ts. discoverAccount calls fetchCurrentUserPrincipal, which sends PROPFIND (Depth: 0) to /.well-known/caldav. It retries the preset serverUrl only for 400, 404, 405, or 501. A non-ok status throws CalendarProviderRequestError. The principal is read from the multistatus body, and a missing principal throws 'CalDAV principal not found.' The returned discoveryUrl is response.url from that PROPFIND. The old GET-based resolveDiscoveryUrl, which adopted any 200 redirect target, is removed. In the reported Radicale flow, a non-DAV page at /.web/ cannot yield a current-user-principal, so discovery no longer adopts it. The calendar-home PROPFIND and href resolution now use the response URL. Residual uncertainty: the PROPFIND redirect path depends on safeFetch (base/utils/request.ts, not inspected within the inspection limit) preserving the PROPFIND method across 301/302 responses. If it did not, the flow would fail loudly with a principal error, not silently adopt a wrong URL. The verdict assumes the method is preserved. The PR test mock is reported to redirect PROPFIND discovery requests, which is consistent with that assumption.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff (mergeBase 4ac1636 to head 858f45d) touches two files. caldav.ts changes are confined to the CalDAV discovery path. These are: removal of resolveDiscoveryUrl, folding discovery URL and principal lookup into fetchCurrentUserPrincipal, removal of the username@host providerAccountId fallback (dead code, because principalUrl is now always non-empty or the call throws), dropping the unused baseUrl parameter from fetchCalendarHomeSet, and resolving hrefs against response.url. All of these directly implement the #15482 fix. The caldav.spec.ts changes add mock discovery scenarios and tests for 401/403 propagation. These support the discovery change. The summary also notes test-infrastructure edits: AVA serial API, a typed Models return without an any cast. These are minor and sit in the same test file as the supporting tests. No change was found that is unrelated to #15482. Inspection of the test file was limited, so its exact contents were not verified.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.13%. Comparing base (4ac1636) to head (858f45d). ⚠️ Report is 3 commits behind head on canary.
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
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.
fix #15482
PR Dependency Tree
This tree was auto-generated by Charcoal
Summary by CodeRabbit