siyuan-note/siyuan · error
CalDAV: calendar object path is invalid
Error message
CalDAV: calendar object path is invalid
What it means
ErrorCalDavCalendarObjectPathInvalid is returned by ParseCalendarObjectPath (kernel/model/caldav.go:110-113) when the file name portion of a calendar object URL does not end with the iCalendar extension '.ics'. The calendar path depth check passed, so the URL targets a calendar, but the last segment is not a well-formed object file name. GetObject/DeleteObject propagate it after path parsing fails.
Source
Thrown at kernel/model/caldav.go:85
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)
calendarPath = PathCleanWithSlash(calendarPath)
objectID = path.Base(objectFileName)
objectFileExt := util.Ext(objectFileName)View on GitHub (pinned to 8641553a1f)
Solutions
- Append the .ics extension to the object file name in the URL before calling the API (ICalendarFileExt = ".ics").
- If the server generates the path, verify it returns URLs ending in .ics as declared by the calendar's resource list.
- Check path building code for dropped extensions (e.g. using path.Base of an ID instead of id + ".ics").
- Confirm the URL depth matches /caldav/principals/main/calendars/<calendar>/<object>.ics (6 segments).
Example fix
// before objectPath := calPath + "/" + eventID obj, err := ParseCalendarObjectPath(objectPath) // ErrorCalDavCalendarObjectPathInvalid // after objectPath := calPath + "/" + eventID + ".ics" obj, err := ParseCalendarObjectPath(objectPath)
Defensive patterns
Strategy: validation
Validate before calling
if !strings.HasSuffix(objectPath, ".ics") {
return fmt.Errorf("calendar object path must end with .ics: %s", objectPath)
}
if _, _, err := model.ParseCalendarObjectPath(objectPath); err != nil {
return err
} Type guard
func hasICalendarExt(objectPath string) bool {
return path.Ext(objectPath) == ".ics"
} Try / catch
if _, _, err := model.ParseCalendarObjectPath(p); err != nil {
if errors.Is(err, model.ErrorCalDavCalendarObjectPathInvalid) {
p = strings.TrimSuffix(p, path.Ext(p)) + ".ics" // normalize once
}
} Prevention
- Build object paths with the ICalendarFileExt constant instead of hard-coded or omitted extensions.
- Normalize client-supplied object URLs early: append .ics when the final segment has no extension.
- Unit-test path builders to assert every generated URL parses via ParseCalendarObjectPath without error.
- Keep object IDs extension-free internally and only add .ics when composing the URL.
When it happens
Trigger: ParseCalendarObjectPath is given a path whose final segment lacks the .ics extension (e.g. /caldav/principals/main/calendars/default/evt-1, .../evt-1.ical, or .../calendars.json), typically via Calendars.GetObject, Calendars.DeleteObject, or a CalDAV request handler routing an object URL.
Common situations: A client PUTs or requests an object without appending .ics (some hand-rolled CalDAV scripts do this); a plugin or integration builds the object URL by concatenation and forgets the extension; a directory listing URL is mistakenly treated as an object URL.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- CalDAV: calendar object not found
- CardDAV: path is invalid
- CardDAV: address book path is invalid
- invalid path
- asset path must be absolute
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/603f683f48864094.
Report an issue: GitHub.