{"record":{"id":"161931398f5b58d6","repo":"nextcloud/server","slug":"the-calendar-calendar-uri-is-already-share","errorCode":null,"errorMessage":"The calendar <{$calendar['uri']}> is already shared to user <$userDestination>.You may use -f to move the calendar while deleting this share.","messagePattern":"The calendar <(.+?)> is already shared to user <\\$userDestination>\\.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":173,"sourceCode":"\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}\n","sourceCodeStart":155,"sourceCodeEnd":181,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/MoveCalendar.php#L155-L181","documentation":"Thrown from checkShares() in occ dav:move-calendar when the calendar is already shared directly with the destination user (share href matches the destination uid). Moving it would create a self-share / duplicate access. With -f the direct share is removed via updateShares() before the move; without it the command aborts with this message (note the missing space after the period in the thrown text).","triggerScenarios":"`occ dav:move-calendar <src> <dst> <name>` where the source calendar was already shared with <dst> — typical when consolidating accounts that already collaborated.","commonSituations":"Offboarding moves where the departing user's calendar had been shared with the successor; migration dry-runs after shares were set up manually.","solutions":["Re-run with --force to drop the now-redundant direct share and complete the move","Or unshare first via the calendar UI / dav share endpoints, then re-run without -f","After the move, confirm the destination user sees exactly one copy of the calendar"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nsrc=\"$1\"; dst=\"$2\"; name=\"$3\"\n# if the calendar is already shared with dst, plan for --force or unshare first\nocc dav:list-calendar-shares \"$dst\" | grep -F \"$name\" && echo \"Note: '$name' appears already shared with $dst\" >&2","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit existing shares between source and destination before account merges","Unshare via UI/API when you want a clean non-forced move","After a forced move, verify the destination sees one calendar, not duplicates"],"tags":["dav","calendar","shares","migration","occ","cli"],"backgroundTag":"share-already-exists","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}