nextcloud/server · error · InvalidArgumentException
User <$userDestination> is not part of the group <$userOrGro
Error message
User <$userDestination> is not part of the group <$userOrGroup> with whom the calendar <{$calendar['uri']}> was shared. You may use -f to move the calendar while deleting this share. What it means
Thrown from checkShares() in occ dav:move-calendar when shareWithGroupMembersOnly() is enabled, the calendar is shared with a group (share href prefix 'groups'), and the destination user is not a member of that group. Moving the calendar would leave an illegal share (share restricted to group members, recipient outside the group). Without -f the command aborts; with -f that group share is deleted via updateShares() and the move proceeds.
Source
Thrown at apps/dav/lib/Command/MoveCalendar.php:162
* Check that moving the calendar won't break shares
*
* @return bool had any shares or not
* @throws \InvalidArgumentException
*/
private function checkShares(array $calendar, string $userOrigin, string $userDestination, bool $force = false): bool {
$shares = $this->calDav->getShares($calendar['id']);
foreach ($shares as $share) {
[, $prefix, $userOrGroup] = explode('/', $share['href'], 3);
/**
* Check that user destination is member of the groups which whom the calendar was shared
* If we ask to force the migration, the share with the group is dropped
*/
if ($this->shareManager->shareWithGroupMembersOnly() === true && $prefix === 'groups' && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]);
} else {
throw new \InvalidArgumentException("User <$userDestination> is not part of the group <$userOrGroup> with whom the calendar <" . $calendar['uri'] . '> was shared. You may use -f to move the calendar while deleting this share.');
}
}
/**
* Check that calendar isn't already shared with user destination
*/
if ($userOrGroup === $userDestination) {
if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/users/' . $userOrGroup]);
} else {
throw new \InvalidArgumentException('The calendar <' . $calendar['uri'] . "> is already shared to user <$userDestination>.You may use -f to move the calendar while deleting this share.");
}
}
}
return count($shares) > 0;
}
}View on GitHub (pinned to ecdeb153ff)
Solutions
- If the destination user should keep the share: add them to the group (`occ group:adduser <group> <dst>`) and re-run without -f
- If the group share is disposable: re-run with --force, which drops that share (sharees lose access)
- Review who the share reached first with `occ dav:list-calendar-shares <member-uid> --calendar-id <id>` or the share list, and notify affected users
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash src="$1"; dst="$2"; name="$3" # if member-only sharing is on, ensure dst is in every group the calendar is shared with share_policy=$(occ config:app:get core shareapi_only_share_with_group_members) if [ "$share_policy" = "yes" ]; then occ user:info "$dst" | sed -n '/^Groups:/,$p' # verify membership covers the shared groups fi occ dav:move-calendar "$src" "$dst" "$name"
Prevention
- Before moves, list the calendar's shares and the destination's groups
- Add the destination user to relevant groups when the share must survive
- Use --force knowingly: it silently deletes the blocking group share
When it happens
Trigger: `occ dav:move-calendar <src> <dst> <name>` where the source calendar is shared with principals/groups/<g>, the instance enforces 'Share with group members only', and <dst> is not in <g>.
Common situations: Moving a team calendar to a user from another department during offboarding; cross-group account consolidation on instances with member-only sharing enforced.
Related errors
- The calendar <{$calendar['uri']}> is already shared to user
- User $user is unknown
- User <$userOrigin> is unknown.
- User <$userDestination> is unknown.
- User <$userOrigin> has no calendar named <$name>. You can ru
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/502f29d87f9dc3fd.
Report an issue: GitHub.