{"record":{"id":"52545f61aa6f0538","repo":"nextcloud/server","slug":"a-calendar-object-with-uri-newuri-already-exists","errorCode":null,"errorMessage":"A calendar object with URI $newUri already exists in calendar $calendarId, therefore this object can't be moved into the trashbin","messagePattern":"A calendar object with URI \\$newUri already exists in calendar \\$calendarId, therefore this object can't be moved into the trashbin","errorType":"exception","errorClass":"Sabre\\DAV\\Exception\\Forbidden","httpStatus":403,"severity":"error","filePath":"apps/dav/lib/CalDAV/CalDavBackend.php","lineNumber":1820,"sourceCode":"\t\t\t\tif (!empty($pathInfo['extension'])) {\n\t\t\t\t\t// Append a suffix to \"free\" the old URI for recreation\n\t\t\t\t\t$newUri = sprintf(\n\t\t\t\t\t\t'%s-deleted.%s',\n\t\t\t\t\t\t$pathInfo['filename'],\n\t\t\t\t\t\t$pathInfo['extension']\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t$newUri = sprintf(\n\t\t\t\t\t\t'%s-deleted',\n\t\t\t\t\t\t$pathInfo['filename']\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Try to detect conflicts before the DB does\n\t\t\t\t// As unlikely as it seems, this can happen when the user imports, then deletes, imports and deletes again\n\t\t\t\t$newObject = $this->getCalendarObject($calendarId, $newUri, $calendarType);\n\t\t\t\tif ($newObject !== null) {\n\t\t\t\t\tthrow new Forbidden(\"A calendar object with URI $newUri already exists in calendar $calendarId, therefore this object can't be moved into the trashbin\");\n\t\t\t\t}\n\n\t\t\t\t$qb = $this->db->getQueryBuilder();\n\t\t\t\t$markObjectDeletedQuery = $qb->update('calendarobjects')\n\t\t\t\t\t->set('deleted_at', $qb->createNamedParameter(time(), IQueryBuilder::PARAM_INT))\n\t\t\t\t\t->set('uri', $qb->createNamedParameter($newUri))\n\t\t\t\t\t->where(\n\t\t\t\t\t\t$qb->expr()->eq('calendarid', $qb->createNamedParameter($calendarId)),\n\t\t\t\t\t\t$qb->expr()->eq('calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),\n\t\t\t\t\t\t$qb->expr()->eq('uri', $qb->createNamedParameter($objectUri))\n\t\t\t\t\t);\n\t\t\t\t$markObjectDeletedQuery->executeStatement();\n\n\t\t\t\t$calendarData = $this->getCalendarById($calendarId);\n\t\t\t\tif ($calendarData !== null) {\n\t\t\t\t\t$this->dispatcher->dispatchTyped(\n\t\t\t\t\t\tnew CalendarObjectMovedToTrashEvent(\n\t\t\t\t\t\t\t$calendarId,","sourceCodeStart":1802,"sourceCodeEnd":1838,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/CalDAV/CalDavBackend.php#L1802-L1838","documentation":"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.","triggerScenarios":"Thrown at apps/dav/lib/CalDAV/CalDavBackend.php:1820 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}