nextcloud/server · error · InvalidArgumentException
Calendar <$calendarId> is deleted
Error message
Calendar <$calendarId> is deleted
What it means
InvalidArgumentException thrown by occ dav:import-calendar (apps/dav/lib/Command/ImportCalendar.php:95) when CalendarImpl::isDeleted() returns true - the calendar is in the trash bin (deletion scheduled / deleted_at set) and must be restored before data can be imported.
Source
Thrown at apps/dav/lib/Command/ImportCalendar.php:95
$showErrors = $input->getOption('show-errors');
if (!$this->userManager->userExists($userId)) {
throw new InvalidArgumentException("User <$userId> not found.");
}
// retrieve calendar and evaluate if import is supported and writeable
$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId, [$calendarId]);
if ($calendars === []) {
throw new InvalidArgumentException("Calendar <$calendarId> not found");
}
$calendar = $calendars[0];
if (!$calendar instanceof CalendarImpl) {
throw new InvalidArgumentException("Calendar <$calendarId> doesn't support this function");
}
if (!$calendar->isWritable()) {
throw new InvalidArgumentException("Calendar <$calendarId> is not writeable");
}
if ($calendar->isDeleted()) {
throw new InvalidArgumentException("Calendar <$calendarId> is deleted");
}
// construct options object
$options = new CalendarImportOptions();
$options->setSupersede($supersede);
if ($errors !== null) {
$options->setErrors($errors);
}
if ($validation !== null) {
$options->setValidate($validation);
}
$options->setFormat($format);
$options->setCounts(true);
// evaluate if a valid location was given and is usable otherwise default to stdin
if ($location !== null) {
$stream = fopen($location, 'r');
if ($stream === false) {
throw new InvalidArgumentException("Location <$location> is not valid. Cannot open location for read operation.");
}View on GitHub (pinned to ecdeb153ff)
Solutions
- Restore the calendar from trash (Calendar app trash bin or occ trashbin restoration) and re-run
- Or pick/create a different calendar as the import target
- occ dav:cleanup to purge deleted calendars, then recreate the URI fresh
Defensive patterns
Strategy: validation
Validate before calling
$calendar = $calendars[0];
if ($calendar instanceof \OCA\DAV\CalDAV\CalendarImpl && $calendar->isDeleted()) {
// restore from trash first, or pick another target
} Type guard
$isDeletedCalendar = fn ($c): bool =>
$c instanceof \OCA\DAV\CalDAV\CalendarImpl && $c->isDeleted(); Prevention
- Restore trashed calendars before importing into their URI
- Refresh discovery after user deletions - stale caches list dead URIs
- Use occ dav:cleanup before reusing a deleted calendar's URI
When it happens
Trigger: occ dav:import-calendar alice <uri> ... where the oc_calendars row has deleted_at set because the user deleted it in the Calendar app and it now sits in trash (purged later by occ dav:cleanup).
Common situations: User deleted the calendar and it still appears in legacy listings/PROPFIND caches; import scripts targeting a stale URI; time window before trash purge.
Related errors
- User <$userId> not found.
- Calendar <$calendarId> not found
- Calendar <$calendarId> doesn't support this function
- Calendar <$calendarId> is not writeable
- User <$userId> not found.
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/5adfe7231980e515.
Report an issue: GitHub.