{"record":{"id":"502f29d87f9dc3fd","repo":"nextcloud/server","slug":"user-userdestination-is-not-part-of-the-group","errorCode":null,"errorMessage":"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.","messagePattern":"User <\\$userDestination> is not part of the group <\\$userOrGroup> with whom the calendar <(.+?)> was shared\\. You may use -f to move the calendar while deleting this share\\.","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"apps/dav/lib/Command/MoveCalendar.php","lineNumber":162,"sourceCode":"\t * Check that moving the calendar won't break shares\n\t *\n\t * @return bool had any shares or not\n\t * @throws \\InvalidArgumentException\n\t */\n\tprivate function checkShares(array $calendar, string $userOrigin, string $userDestination, bool $force = false): bool {\n\t\t$shares = $this->calDav->getShares($calendar['id']);\n\t\tforeach ($shares as $share) {\n\t\t\t[, $prefix, $userOrGroup] = explode('/', $share['href'], 3);\n\n\t\t\t/**\n\t\t\t * Check that user destination is member of the groups which whom the calendar was shared\n\t\t\t * If we ask to force the migration, the share with the group is dropped\n\t\t\t */\n\t\t\tif ($this->shareManager->shareWithGroupMembersOnly() === true && $prefix === 'groups' && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {\n\t\t\t\tif ($force) {\n\t\t\t\t\t$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]);\n\t\t\t\t} else {\n\t\t\t\t\tthrow 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.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Check that calendar isn't already shared with user destination\n\t\t\t */\n\t\t\tif ($userOrGroup === $userDestination) {\n\t\t\t\tif ($force) {\n\t\t\t\t\t$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/users/' . $userOrGroup]);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new \\InvalidArgumentException('The calendar <' . $calendar['uri'] . \"> is already shared to user <$userDestination>.You may use -f to move the calendar while deleting this share.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn count($shares) > 0;\n\t}\n}","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/MoveCalendar.php#L144-L180","documentation":"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.","triggerScenarios":"`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>.","commonSituations":"Moving a team calendar to a user from another department during offboarding; cross-group account consolidation on instances with member-only sharing enforced.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nsrc=\"$1\"; dst=\"$2\"; name=\"$3\"\n# if member-only sharing is on, ensure dst is in every group the calendar is shared with\nshare_policy=$(occ config:app:get core shareapi_only_share_with_group_members)\nif [ \"$share_policy\" = \"yes\" ]; then\n  occ user:info \"$dst\" | sed -n '/^Groups:/,$p'   # verify membership covers the shared groups\nfi\nocc dav:move-calendar \"$src\" \"$dst\" \"$name\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["dav","calendar","shares","groups","migration","occ","cli"],"backgroundTag":"group-membership-missing","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}