nextcloud/server · error · InvalidArgumentException
Calendar <$calendarId> not found
Error message
Calendar <$calendarId> not found
What it means
InvalidArgumentException thrown by occ dav:import-calendar (apps/dav/lib/Command/ImportCalendar.php:85) when getCalendarsForPrincipal('principals/users/<uid>', [<uri>]) returns no calendar - the import target URI does not exist for that principal.
Source
Thrown at apps/dav/lib/Command/ImportCalendar.php:85
$userId = $input->getArgument('uid');
$calendarId = $input->getArgument('uri');
$location = $input->getArgument('location');
$format = $input->getOption('format');
$errors = is_numeric($input->getOption('errors')) ? (int)$input->getOption('errors') : null;
$validation = is_numeric($input->getOption('validation')) ? (int)$input->getOption('validation') : null;
$supersede = $input->getOption('supersede');
$showCreated = $input->getOption('show-created');
$showUpdated = $input->getOption('show-updated');
$showSkipped = $input->getOption('show-skipped');
$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) {View on GitHub (pinned to ecdeb153ff)
Solutions
- PROPFIND /remote.php/dav/calendars/alice/ (or query oc_calendars.uri) to get the exact URI
- Create the target first with a CalDAV client or use an existing calendar URI
- Re-run with the case-sensitive URI
Example fix
# before occ dav:import-calendar alice Personal calendar.ics # after (uri is lowercase 'personal') occ dav:import-calendar alice personal calendar.ics
Defensive patterns
Strategy: validation
Validate before calling
$uris = array_map(fn ($c) => $c->getUri(),
$calendarManager->getCalendarsForPrincipal('principals/users/' . $uid));
in_array($uri, $uris, true) || throw new RuntimeException('Unknown calendar uri'); Prevention
- Discover URIs with PROPFIND on /remote.php/dav/calendars/<uid>/
- Calendar URIs are case-sensitive
- Import targets must belong to the same principal
When it happens
Trigger: occ dav:import-calendar alice <uri> calendar.ics where <uri> is not a calendar of alice (typo, wrong case, other principal, or app calendar registered under a different id).
Common situations: Using display names instead of URIs; importing into a calendar that was deleted or belongs to a shared/delegated principal; case mismatches.
Related errors
- Calendar <$calendarId> not found.
- User <$userId> not found.
- User <$userId> not found.
- Calendar <$calendarId> doesn't support this function
- Calendar <$calendarId> is not writeable
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/8a5fb1195a54c1d1.
Report an issue: GitHub.