nextcloud/server · error · InvalidArgumentException
User <$userId> not found.
Error message
User <$userId> not found.
What it means
Symfony\Component\Console\Exception\InvalidArgumentException thrown by the occ dav:export-calendar command (apps/dav/lib/Command/ExportCalendar.php:61) when the user id passed as first argument does not exist in the user backend. The command refuses to continue before touching the calendar manager.
Source
Thrown at apps/dav/lib/Command/ExportCalendar.php:61
#[\Override]
protected function configure(): void {
$this->setName('calendar:export')
->setDescription('Export calendar data from supported calendars to disk or stdout')
->addArgument('uid', InputArgument::REQUIRED, 'Id of system user')
->addArgument('uri', InputArgument::REQUIRED, 'URI of calendar')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'Format of output (ical, jcal, xcal) defaults to ical', 'ical')
->addOption('location', null, InputOption::VALUE_REQUIRED, 'Location of where to write the output. Defaults to stdout');
}
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
$userId = $input->getArgument('uid');
$calendarId = $input->getArgument('uri');
$format = $input->getOption('format');
$location = $input->getOption('location');
if (!$this->userManager->userExists($userId)) {
throw new InvalidArgumentException("User <$userId> not found.");
}
// retrieve calendar and evaluate if export is supported
$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId, [$calendarId]);
if ($calendars === []) {
throw new InvalidArgumentException("Calendar <$calendarId> not found.");
}
$calendar = $calendars[0];
if (!$calendar instanceof ICalendarExport) {
throw new InvalidArgumentException("Calendar <$calendarId> does not support exporting");
}
// construct options object
$options = new CalendarExportOptions();
// evaluate if provided format is supported
if (!in_array($format, ExportService::FORMATS, true)) {
throw new InvalidArgumentException("Format <$format> is not valid.");
}
$options->setFormat($format);
// evaluate if a valid location was given and is usable otherwise output to stdoutView on GitHub (pinned to ecdeb153ff)
Solutions
- List valid ids with occ user:list and re-run with the exact uid
- If the user should come from LDAP/external backend, verify that backend is configured and reachable (occ user:lastseen, occ ldap:test-config)
- Re-run the command with a uid that userExists() confirms
Example fix
# before occ dav:export-calendar alic example-personal # after occ user:list | grep -i alic # find exact id, e.g. 'alice' occ dav:export-calendar alice personal
Defensive patterns
Strategy: validation
Validate before calling
// programmatic callers: verify the uid first
if (!$userManager->userExists($uid)) {
throw new RuntimeException("Unknown user $uid - run occ user:list");
} Try / catch
try {
$commandTester->execute(['uid' => $uid, 'uri' => $uri]);
} catch (\Symfony\Component\Console\Exception\InvalidArgumentException $e) {
// message contains the offending argument; fix inputs and re-run
} Prevention
- Pipe candidate uids through occ user:list in automation scripts
- Validate arguments before invoking occ commands
- Resolve users before batch exports
When it happens
Trigger: occ dav:export-calendar <uid> <calendar-uri> [--format=ical|jcal|xcal] [--location=...] where <uid> is not returned by IUserManager::userExists() - typo'd id, deleted user, or wrong user backend (e.g. user only exists in LDAP but LDAP is unreachable).
Common situations: Typo in the uid; running the command before provisioning the user; LDAP/external user backend temporarily unavailable so userExists() fails; copy-pasting examples that contain placeholder names.
Related errors
- Calendar <$calendarId> not found.
- User <$userId> not found.
- Calendar <$calendarId> does not support exporting
- Calendar <$calendarId> not found
- Format <$format> is not valid.
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/554deb92b43b857e.
Report an issue: GitHub.