nextcloud/server · error · Sabre\DAV\Exception\Forbidden

A calendar object with URI $newUri already exists in calenda

Error message

A calendar object with URI $newUri already exists in calendar $calendarId, therefore this object can't be moved into the trashbin

What it means

Error "A calendar object with URI $newUri already exists in calendar $calendarId, therefore this object can't be moved into the trashbin" thrown in nextcloud/server.

Source

Thrown at apps/dav/lib/CalDAV/CalDavBackend.php:1820

				if (!empty($pathInfo['extension'])) {
					// Append a suffix to "free" the old URI for recreation
					$newUri = sprintf(
						'%s-deleted.%s',
						$pathInfo['filename'],
						$pathInfo['extension']
					);
				} else {
					$newUri = sprintf(
						'%s-deleted',
						$pathInfo['filename']
					);
				}

				// Try to detect conflicts before the DB does
				// As unlikely as it seems, this can happen when the user imports, then deletes, imports and deletes again
				$newObject = $this->getCalendarObject($calendarId, $newUri, $calendarType);
				if ($newObject !== null) {
					throw new Forbidden("A calendar object with URI $newUri already exists in calendar $calendarId, therefore this object can't be moved into the trashbin");
				}

				$qb = $this->db->getQueryBuilder();
				$markObjectDeletedQuery = $qb->update('calendarobjects')
					->set('deleted_at', $qb->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
					->set('uri', $qb->createNamedParameter($newUri))
					->where(
						$qb->expr()->eq('calendarid', $qb->createNamedParameter($calendarId)),
						$qb->expr()->eq('calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
						$qb->expr()->eq('uri', $qb->createNamedParameter($objectUri))
					);
				$markObjectDeletedQuery->executeStatement();

				$calendarData = $this->getCalendarById($calendarId);
				if ($calendarData !== null) {
					$this->dispatcher->dispatchTyped(
						new CalendarObjectMovedToTrashEvent(
							$calendarId,

View on GitHub (pinned to ecdeb153ff)

When it happens

Trigger: Thrown at apps/dav/lib/CalDAV/CalDavBackend.php:1820 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/52545f61aa6f0538. Report an issue: GitHub.