nextcloud/server · error · InvalidArgumentException
Unable to find a suitable calendar name for <$userDestinatio
Error message
Unable to find a suitable calendar name for <$userDestination> with initial name <$name>.
What it means
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.
Source
Thrown at apps/dav/lib/Command/MoveCalendar.php:91
$name = $input->getArgument('name');
$newName = null;
$calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name);
if ($calendar === null) {
throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user.");
}
// Calendar already exists
if ($this->calendarExists($userDestination, $name)) {
if ($input->getOption('force')) {
// Try to find a suitable name
$newName = $this->getNewCalendarName($userDestination, $name);
// If we didn't find a suitable value after all the iterations, give up
if ($this->calendarExists($userDestination, $newName)) {
throw new \InvalidArgumentException("Unable to find a suitable calendar name for <$userDestination> with initial name <$name>.");
}
} else {
throw new \InvalidArgumentException("User <$userDestination> already has a calendar named <$name>.");
}
}
$hadShares = $this->checkShares($calendar, $userOrigin, $userDestination, $input->getOption('force'));
if ($hadShares) {
/**
* Warn that share links have changed if there are shares
*/
$this->io->note([
'Please note that moving calendar ' . $calendar['uri'] . " from user <$userOrigin> to <$userDestination> has caused share links to change.",
'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\""
]);
}
$this->calDav->moveCalendar($name, self::URI_USERS . $userOrigin, self::URI_USERS . $userDestination, $newName);View on GitHub (pinned to ecdeb153ff)
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
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
src="$1"; dst="$2"; name="$3"
# pre-check the 11 colliding names --force would try
for n in "$name" $(for i in $(seq 1 10); do echo "$name-$i"; done); do
if occ dav:list-calendars "$dst" | awk 'NR>1 {print $1}' | grep -Fxq "$n"; then
echo "'$n' blocks the forced move at destination" >&2
fi
done Prevention
- 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
When it happens
Trigger: `occ dav:move-calendar <src> <dst> <name> --force` where the destination has eleven colliding calendar names (the original plus all ten suffixed variants).
Common situations: The same calendar was moved/merged repeatedly into the destination during account consolidation, exhausting the -1..-10 suffixes; scripted re-runs after partial cleanup.
Related errors
- User <$userDestination> already has a calendar named <$name>
- User <$userOrigin> is unknown.
- User <$userDestination> is unknown.
- User <$userOrigin> has no calendar named <$name>. You can ru
- User <$userDestination> is not part of the group <$userOrGro
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/f1141146d7fa1dc4.
Report an issue: GitHub.