siyuan-note/siyuan · error
CalDAV: calendar path is invalid
Error message
CalDAV: calendar path is invalid
What it means
ErrorCalDavCalendarPathInvalid is returned by ParseCalendarObjectPath / calendar path parsing when the depth of the given CalDAV path does not match calDavPathDepth_Calendar, i.e. the path has too few or too many segments to identify a calendar.
Solutions
- Use the exact path shape returned by ListCalendars instead of constructing it manually
- Check GetCalDavPathDepth on the path before calling
- Normalize stray leading/trailing slashes that alter segment depth
Example fix
// before
ParseCalendarObjectPath("/dav/caldav")
// after
ParseCalendarObjectPath("/dav/caldav/calendars/mycal/") // correct depth Defensive patterns
Strategy: validation
Validate before calling
if GetCalDavPathDepth(path) != calDavPathDepth_Calendar {
return fmt.Errorf("refusing: %q is not a calendar-depth path", path)
} Try / catch
if errors.Is(err, ErrorCalDavCalendarPathInvalid) {
// log the offending path and return 400 to the CalDAV client
} Prevention
- Build calendar URLs from server-returned hrefs only
- Keep a single URL-builder helper so segment counts stay consistent
- Watch out for trailing-slash handling that changes depth
When it happens
Trigger: Calling ParseCalendarObjectPath (or handlers using it) with a calendar path whose GetCalDavPathDepth result differs from calDavPathDepth_Calendar.
Common situations: Client building URLs manually and omitting or duplicating path segments; mixing up calendar-object paths (deeper) with calendar paths; trailing/missing slashes changing segment counts.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- CalDAV: calendar object path is invalid
- CardDAV: address book path is invalid
- CardDAV: path is invalid
- data?.msg || data?.message ||…
- invalid asset path
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/62bedc8d0507202d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/caldav.go:84
calendarSupportedComponentSet = []string{"VEVENT", "VTODO"}
defaultCalendar = caldav.Calendar{
Path: CalDavDefaultCalendarPath,
Name: CalDavDefaultCalendarName,
Description: "Default calendar",
MaxResourceSize: calendarMaxResourceSize,
SupportedComponentSet: calendarSupportedComponentSet,
}
calendars = Calendars{
loaded: false,
changed: false,
lock: sync.Mutex{},
calendars: sync.Map{},
calendarsMetaData: []*caldav.Calendar{},
}
ErrorCalDavCalendarNotFound = errors.New("CalDAV: calendar not found")
ErrorCalDavCalendarPathInvalid = errors.New("CalDAV: calendar path is invalid")
ErrorCalDavCalendarObjectNotFound = errors.New("CalDAV: calendar object not found")
ErrorCalDavCalendarObjectPathInvalid = errors.New("CalDAV: calendar object path is invalid")
)
// CalendarsMetaDataFilePath returns the absolute path of the calendars' meta data file
func CalendarsMetaDataFilePath() string {
return DavPath2DirectoryPath(CalDavCalendarsMetaDataFilePath)
}
func GetCalDavPathDepth(urlPath string) CalDavPathDepth {
urlPath = PathCleanWithSlash(urlPath)
return CalDavPathDepth(len(strings.Split(urlPath, "/")) - 1)
}
// GetCardDavPathDepth parses
func ParseCalendarObjectPath(objectPath string) (calendarPath string, objectID string, err error) {
calendarPath, objectFileName := path.Split(objectPath)View on GitHub (pinned to 9f775e8a12)