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

Can not restore calendar $id because a calendar object with

Error message

Can not restore calendar $id because a calendar object with the URI $restoreUri already exists

What it means

Error "Can not restore calendar $id because a calendar object with the URI $restoreUri already exists" thrown in nextcloud/server.

Source

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

		}, $this->db);
	}

	/**
	 * @param mixed $objectData
	 *
	 * @throws Forbidden
	 */
	public function restoreCalendarObject(array $objectData): void {
		$this->cachedObjects = [];
		$this->atomic(function () use ($objectData): void {
			$id = (int)$objectData['id'];
			$restoreUri = str_replace('-deleted.ics', '.ics', $objectData['uri']);
			$targetObject = $this->getCalendarObject(
				$objectData['calendarid'],
				$restoreUri
			);
			if ($targetObject !== null) {
				throw new Forbidden("Can not restore calendar $id because a calendar object with the URI $restoreUri already exists");
			}

			$qb = $this->db->getQueryBuilder();
			$update = $qb->update('calendarobjects')
				->set('uri', $qb->createNamedParameter($restoreUri))
				->set('deleted_at', $qb->createNamedParameter(null))
				->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
			$update->executeStatement();

			// Make sure this change is tracked in the changes table
			$qb2 = $this->db->getQueryBuilder();
			$selectObject = $qb2->select('calendardata', 'uri', 'calendarid', 'calendartype')
				->selectAlias('componenttype', 'component')
				->from('calendarobjects')
				->where($qb2->expr()->eq('id', $qb2->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
			$result = $selectObject->executeQuery();
			$row = $result->fetchAssociative();
			$result->closeCursor();

View on GitHub (pinned to ecdeb153ff)

When it happens

Trigger: Thrown at apps/dav/lib/CalDAV/CalDavBackend.php:1866 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/77f3e24171b88bdc. Report an issue: GitHub.