{"record":{"id":"5adfe7231980e515","repo":"nextcloud/server","slug":"calendar-calendarid-is-deleted","errorCode":null,"errorMessage":"Calendar <$calendarId> is deleted","messagePattern":"Calendar <\\$calendarId> is deleted","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"apps/dav/lib/Command/ImportCalendar.php","lineNumber":95,"sourceCode":"\t\t$showErrors = $input->getOption('show-errors');\n\n\t\tif (!$this->userManager->userExists($userId)) {\n\t\t\tthrow new InvalidArgumentException(\"User <$userId> not found.\");\n\t\t}\n\t\t// retrieve calendar and evaluate if import is supported and writeable\n\t\t$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId, [$calendarId]);\n\t\tif ($calendars === []) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> not found\");\n\t\t}\n\t\t$calendar = $calendars[0];\n\t\tif (!$calendar instanceof CalendarImpl) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> doesn't support this function\");\n\t\t}\n\t\tif (!$calendar->isWritable()) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> is not writeable\");\n\t\t}\n\t\tif ($calendar->isDeleted()) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> is deleted\");\n\t\t}\n\t\t// construct options object\n\t\t$options = new CalendarImportOptions();\n\t\t$options->setSupersede($supersede);\n\t\tif ($errors !== null) {\n\t\t\t$options->setErrors($errors);\n\t\t}\n\t\tif ($validation !== null) {\n\t\t\t$options->setValidate($validation);\n\t\t}\n\t\t$options->setFormat($format);\n\t\t$options->setCounts(true);\n\t\t// evaluate if a valid location was given and is usable otherwise default to stdin\n\t\tif ($location !== null) {\n\t\t\t$stream = fopen($location, 'r');\n\t\t\tif ($stream === false) {\n\t\t\t\tthrow new InvalidArgumentException(\"Location <$location> is not valid. Cannot open location for read operation.\");\n\t\t\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/ImportCalendar.php#L77-L113","documentation":"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.","triggerScenarios":"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).","commonSituations":"User deleted the calendar and it still appears in legacy listings/PROPFIND caches; import scripts targeting a stale URI; time window before trash purge.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$calendar = $calendars[0];\nif ($calendar instanceof \\OCA\\DAV\\CalDAV\\CalendarImpl && $calendar->isDeleted()) {\n    // restore from trash first, or pick another target\n}","typeGuard":"$isDeletedCalendar = fn ($c): bool =>\n    $c instanceof \\OCA\\DAV\\CalDAV\\CalendarImpl && $c->isDeleted();","tryCatchPattern":null,"preventionTips":["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"],"tags":["occ","cli","import","calendar","caldav","trashbin","deleted-resource"],"backgroundTag":"resource-already-deleted","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}