siyuan-note/siyuan · error

CalDAV: calendar not found

Error message

CalDAV: calendar not found

What it means

ErrorCalDavCalendarNotFound is the sentinel error returned by the CalDAV storage layer when the requested calendar path does not resolve to a known calendar in the in-memory calendars sync.Map. GetObject, DeleteObject, GetCalendar, DeleteCalendar, PutCalendarObject and ListCalendarObjects all return it when the calendar lookup misses.

Solutions

  1. List available calendars first and use a returned calendar path
  2. Reload/refresh CalDAV state (restart or re-list) so the calendars map is populated
  3. Recreate the calendar if it was intentionally deleted

Example fix

// before
cal, err := GetCalendar("/dav/caldav/nonexistent/")
// after
homesteads, _, _ := ListCalendars()
// pick a valid path from homesteads before calling GetCalendar
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: check existence first
if _, ok := calendars.Load(calendarPath); !ok { return nil, handleMissing() }

Try / catch

if errors.Is(err, ErrorCalDavCalendarNotFound) {
    // refresh calendar list and retry once, else surface 404 to client
}

Prevention

When it happens

Trigger: Calling GetCalendar/DeleteCalendar/PutCalendarObject/ListCalendarObjects with a calendar path not present in the calendars map, or GetObject/DeleteObject with an object whose parent calendar was not found.

Common situations: Client caching a stale calendar URL after the calendar was deleted or after workspace reload; typo in the calendar path segment; CalDAV client accessing a calendar before the server has loaded its metadata.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/e1bf4daf7caffa21. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/caldav.go:83

	calendarMaxResourceSize       int64 = 0
	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) {

View on GitHub (pinned to 9f775e8a12)