{"record":{"id":"492581182a63809b","repo":"nextcloud/server","slug":"user-userdestination-already-has-a-calendar-nam","errorCode":null,"errorMessage":"User <$userDestination> already has a calendar named <$name>.","messagePattern":"User <\\$userDestination> already has a calendar named <\\$name>\\.","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"apps/dav/lib/Command/MoveCalendar.php","lineNumber":94,"sourceCode":"\n\t\t$calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name);\n\n\t\tif ($calendar === null) {\n\t\t\tthrow new \\InvalidArgumentException(\"User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user.\");\n\t\t}\n\n\t\t// Calendar already exists\n\t\tif ($this->calendarExists($userDestination, $name)) {\n\t\t\tif ($input->getOption('force')) {\n\t\t\t\t// Try to find a suitable name\n\t\t\t\t$newName = $this->getNewCalendarName($userDestination, $name);\n\n\t\t\t\t// If we didn't find a suitable value after all the iterations, give up\n\t\t\t\tif ($this->calendarExists($userDestination, $newName)) {\n\t\t\t\t\tthrow new \\InvalidArgumentException(\"Unable to find a suitable calendar name for <$userDestination> with initial name <$name>.\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new \\InvalidArgumentException(\"User <$userDestination> already has a calendar named <$name>.\");\n\t\t\t}\n\t\t}\n\n\t\t$hadShares = $this->checkShares($calendar, $userOrigin, $userDestination, $input->getOption('force'));\n\t\tif ($hadShares) {\n\t\t\t/**\n\t\t\t * Warn that share links have changed if there are shares\n\t\t\t */\n\t\t\t$this->io->note([\n\t\t\t\t'Please note that moving calendar ' . $calendar['uri'] . \" from user <$userOrigin> to <$userDestination> has caused share links to change.\",\n\t\t\t\t'Sharees will need to change \"example.com/remote.php/dav/calendars/uid/' . $calendar['uri'] . \"_shared_by_$userOrigin\\\" to \\\"example.com/remote.php/dav/calendars/uid/\" . $newName ?: $calendar['uri'] . \"_shared_by_$userDestination\\\"\"\n\t\t\t]);\n\t\t}\n\n\t\t$this->calDav->moveCalendar($name, self::URI_USERS . $userOrigin, self::URI_USERS . $userDestination, $newName);\n\n\t\t$this->io->success(\"Calendar <$name> was moved from user <$userOrigin> to <$userDestination>\" . ($newName ? \" as <$newName>\" : ''));\n\t\treturn self::SUCCESS;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/MoveCalendar.php#L76-L112","documentation":"Thrown by occ dav:move-calendar when the destination user already owns a calendar with the same URI and --force was not given. It is the non-forced branch of the conflict check; with --force the command instead auto-renames the incoming calendar to <name>-N. Aborted before any share checks or the actual move, so state is unchanged.","triggerScenarios":"`occ dav:move-calendar <src> <dst> <name>` without -f while calendarExists(dst, name) is true, e.g. both users have a calendar URI 'personal'.","commonSituations":"Merging two accounts that both have default-like calendar URIs (personal, work); repeated migration attempts after earlier partial runs.","solutions":["Add --force to let the moved calendar be renamed automatically (<name>-1 etc.) and keep both","Or first delete/rename the destination calendar (`occ dav:delete-calendar <dst> <name>`) if it should be replaced, then re-run without -f","Check `occ dav:list-calendars <destinationuid>` beforehand to decide which option fits"],"exampleFix":"# before\nocc dav:move-calendar alice bob personal\n# User <bob> already has a calendar named <personal>.\n\n# after: keep both, incoming becomes personal-1\nocc dav:move-calendar alice bob personal --force","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nsrc=\"$1\"; dst=\"$2\"; name=\"$3\"; force=\"${4:-}\"\nif [ -z \"$force\" ] && occ dav:list-calendars \"$dst\" | awk 'NR>1 {print $1}' | grep -Fxq \"$name\"; then\n  echo \"Destination already has '$name' — pass --force or remove it first\" >&2; exit 1\nfi\nocc dav:move-calendar \"$src\" \"$dst\" \"$name\" $force","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-flight check destination URIs before every move","Decide deliberately between replace (delete first) and keep-both (--force auto-rename)","Communicate the resulting -N URIs to users of shared calendars after a forced move"],"tags":["dav","calendar","migration","name-conflict","occ","cli"],"backgroundTag":"resource-name-conflict","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}