nextcloud/server · error · InvalidArgumentException
User <$user> is unknown.
Error message
User <$user> is unknown.
What it means
Thrown by occ dav:list-addressbooks when the required uid argument does not correspond to an existing user (IUserManager::userExists() returns false). The check runs before CardDavBackend::getAddressBooksForUser() is called, so it is a pure input-validation failure with no side effects. The angle brackets in the message are literal formatting around the interpolated user id.
Source
Thrown at apps/dav/lib/Command/ListAddressbooks.php:41
private CardDavBackend $cardDavBackend,
) {
parent::__construct('dav:list-addressbooks');
}
#[\Override]
protected function configure(): void {
$this
->setDescription('List all addressbooks of a user')
->addArgument('uid',
InputArgument::REQUIRED,
'User for whom all addressbooks will be listed');
}
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $input->getArgument('uid');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> is unknown.");
}
$addressBooks = $this->cardDavBackend->getAddressBooksForUser("principals/users/$user");
$addressBookTableData = [];
foreach ($addressBooks as $book) {
// skip system / contacts integration address book
if ($book['uri'] === SystemAddressbook::URI_SHARED) {
continue;
}
$readOnly = false;
$readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
if (isset($book[$readOnlyIndex])) {
$readOnly = $book[$readOnlyIndex];
}
$addressBookTableData[] = [View on GitHub (pinned to ecdeb153ff)
Solutions
- Confirm the exact id with `occ user:list` (or `occ user:info <uid>`)
- If the user comes from LDAP, check the backend connection and run the LDAP sync
- Fix the calling script to validate ids against `occ user:list` before invoking the command
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
uid="$1"
occ user:info "$uid" >/dev/null 2>&1 || { echo "Unknown user: $uid" >&2; exit 1; }
occ dav:list-addressbooks "$uid" Type guard
function isValidUid(string $uid): bool {
return \OC::$server->getUserManager()->userExists($uid);
} Prevention
- Validate uids against `occ user:list` in automation before invoking dav commands
- For external backends, verify backend availability before batch runs
- Quote uids to avoid shell mangling of special characters
When it happens
Trigger: `occ dav:list-addressbooks <uid>` with a typo'd, deleted, or not-yet-provisioned user id; empty string passed via scripting; user exists only in an external backend that is currently unavailable (LDAP server down) so userExists() returns false.
Common situations: Script iterates over a stale user list; user was renamed or deleted between listing and command run; LDAP/external user backend offline or not provisioned; CI runs against a fresh instance without seeded users.
Related errors
- User $user is unknown
- User <$user> is unknown.
- User $user is unknown
- User <$userOrigin> is unknown.
- User <$userDestination> is unknown.
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/c8a091b1d5d8aa45.
Report an issue: GitHub.