nextcloud/server · error · InvalidArgumentException
User $user is unknown
Error message
User $user is unknown
What it means
InvalidArgumentException from the occ dav:clear-calendar-unshares command when the required uid argument does not match an existing user (userManager->userExists() returns false). The command aborts before touching the calendar share database.
Source
Thrown at apps/dav/lib/Command/ClearCalendarUnshares.php:60
private SharingMapper $mapper,
) {
parent::__construct();
}
#[\Override]
protected function configure(): void {
$this->addArgument(
'uid',
InputArgument::REQUIRED,
'User whose unshares to clear'
);
}
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = (string)$input->getArgument('uid');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User $user is unknown");
}
$principal = $this->principal->getPrincipalByPath('principals/users/' . $user);
if ($principal === null) {
throw new \InvalidArgumentException("Unable to fetch principal for user $user ");
}
$shares = $this->mapper->getSharesByPrincipals([$principal['uri']], 'calendar');
$unshares = array_filter($shares, static fn ($share) => $share['access'] === BackendAlias::ACCESS_UNSHARED);
if (count($unshares) === 0) {
$output->writeln("User $user has no calendar unshares");
return self::SUCCESS;
}
$rows = array_map(fn ($share) => $this->formatCalendarUnshare($share), $shares);
$table = new Table($output);View on GitHub (pinned to ecdeb153ff)
Solutions
- List valid ids with occ user:list and re-run with the exact id
- Verify a single user with occ user:info <uid> first
- In automation, resolve the uid from your directory/LDAP source before invoking the command
Example fix
# before occ dav:clear-calendar-unshares jdoe@example.com # after: use the exact user id (see occ user:list) occ user:list occ dav:clear-calendar-unshares jdoe
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/bash uid="$1" if ! occ user:info "$uid" >/dev/null 2>&1; then echo "unknown user: $uid" >&2; exit 1 fi occ dav:clear-calendar-unshares "$uid"
Prevention
- Resolve uids from occ user:list / your directory before invoking
- Remember the uid is a backend id, not an email address
- Quote arguments in scripts
When it happens
Trigger: Running occ dav:clear-calendar-unshares <uid> where uid is misspelled, is an email address instead of the user id, contains wrong case, or refers to a deleted user.
Common situations: Automation scripts passing the mail address where the backend user id is expected; LDAP-provisioned users whose id differs from the visible name; copy-paste of uids from a different environment.
Related errors
- User <$userId> not found.
- User <$userId> not found.
- Unable to fetch principal for user $user
- User <$user> in unknown.
- User <$user> in unknown.
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/8da1560f38c16db3.
Report an issue: GitHub.