{"record":{"id":"f1141146d7fa1dc4","repo":"nextcloud/server","slug":"unable-to-find-a-suitable-calendar-name-for-user","errorCode":null,"errorMessage":"Unable to find a suitable calendar name for <$userDestination> with initial name <$name>.","messagePattern":"Unable to find a suitable calendar name for <\\$userDestination> with initial name <\\$name>\\.","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"apps/dav/lib/Command/MoveCalendar.php","lineNumber":91,"sourceCode":"\n\t\t$name = $input->getArgument('name');\n\t\t$newName = null;\n\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);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/MoveCalendar.php#L73-L109","documentation":"Thrown by occ dav:move-calendar when --force was given, a name conflict existed at the destination, and getNewCalendarName() could not find a free name. That helper only tries <name>-1 through <name>-10, so this error means the destination user already has calendars named <name>, <name>-1, ... <name>-10. The move is aborted before moveCalendar() is called.","triggerScenarios":"`occ dav:move-calendar <src> <dst> <name> --force` where the destination has eleven colliding calendar names (the original plus all ten suffixed variants).","commonSituations":"The same calendar was moved/merged repeatedly into the destination during account consolidation, exhausting the -1..-10 suffixes; scripted re-runs after partial cleanup.","solutions":["Run `occ dav:list-calendars <destinationuid>` and delete or rename the <name>-N calendars that block the move","Re-run with --force (the suffix search restarts from -1)","Alternatively rename the source calendar URI first (`dav:delete-calendar` after export, or move via export/import) so no collision exists"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nsrc=\"$1\"; dst=\"$2\"; name=\"$3\"\n# pre-check the 11 colliding names --force would try\nfor n in \"$name\" $(for i in $(seq 1 10); do echo \"$name-$i\"; done); do\n  if occ dav:list-calendars \"$dst\" | awk 'NR>1 {print $1}' | grep -Fxq \"$n\"; then\n    echo \"'$n' blocks the forced move at destination\" >&2\n  fi\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before forced moves, list destination calendars and clear <name>-1..-name>-10 collisions","Avoid repeated partial migration runs that accumulate suffixed copies","Track auto-renamed calendars after --force moves so later scripts reference the new URIs"],"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"}