nextcloud/server · error · InvalidArgumentException

User <$userId> not found.

Error message

User <$userId> not found.

What it means

InvalidArgumentException thrown by occ dav:import-calendar (apps/dav/lib/Command/ImportCalendar.php:80) when the first argument uid does not exist in the user backend (IUserManager::userExists() returns false). The command validates the target user before looking up the calendar.

Source

Thrown at apps/dav/lib/Command/ImportCalendar.php:80

			->addOption('show-errors', null, InputOption::VALUE_NONE, 'show all errored items after processing');
	}

	#[\Override]
	protected function execute(InputInterface $input, OutputInterface $output): int {
		$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();

View on GitHub (pinned to ecdeb153ff)

Solutions

  1. occ user:list to confirm the exact uid
  2. Fix/reconnect the user backend if the user should exist, then re-run
  3. Re-run the import with a valid uid

Example fix

# before
occ dav:import-calendar alic personal calendar.ics
# after
occ dav:import-calendar alice personal calendar.ics
Defensive patterns

Strategy: validation

Validate before calling

if (!$userManager->userExists($uid)) {
    throw new RuntimeException("Unknown user $uid");
}

Try / catch

try { /* import */ }
catch (\InvalidArgumentException $e) {
    if (str_contains($e->getMessage(), 'not found')) { /* fix uid, re-run */ }
}

Prevention

When it happens

Trigger: occ dav:import-calendar <uid> <uri> <location> with a non-existent uid: typo, deleted user, or user from an LDAP backend that is currently not resolvable.

Common situations: Import scripts replayed after users were removed; provisioning order mistakes (import before user import); LDAP server down during a batch import.

Related errors


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/d89dc4b678112a40. Report an issue: GitHub.