Repository navigation
Description
Steps to reproduce
- Run Nextcloud 33.0.5 with at least one federated calendar in
oc_calendars_federated. - Let
OCA\DAV\BackgroundJob\FederatedCalendarPeriodicSyncJobsync a remote calendar where the sync report contains deleted objects. - The job calls
FederatedCalendarSyncService::syncOne(), which calls:
$this->backend->deleteCalendarObject(
$calendar->getId(),
$objectUri,
CalDavBackend::CALENDAR_TYPE_FEDERATED,
true
);Expected behaviour
Federated-calendar object deletion should complete without trying to look up a calendar subscription.
Actual behaviour
The background job fails with a TypeError because CalDavBackend::deleteCalendarObject() treats every non-CALENDAR_TYPE_CALENDAR object as a calendar subscription deletion:
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
...
} else {
$subscriptionRow = $this->getSubscriptionById($calendarId);
$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent($calendarId, $subscriptionRow, [], $data));
}For CALENDAR_TYPE_FEDERATED (2), getSubscriptionById($calendarId) returns null, and CachedCalendarObjectDeletedEvent requires an array for $subscriptionData.
Sanitized stack trace excerpt:
Error while running background job OCA\DAV\BackgroundJob\FederatedCalendarPeriodicSyncJob
TypeError: OCA\DAV\Events\CachedCalendarObjectDeletedEvent::__construct():
Argument #2 ($subscriptionData) must be of type array, null given,
called in apps/dav/lib/CalDAV/CalDavBackend.php on line 1588
#0 apps/dav/lib/CalDAV/CalDavBackend.php(1588): OCA\DAV\Events\CachedCalendarObjectDeletedEvent->__construct()
#1 lib/public/AppFramework/Db/TTransactional.php(45): OCA\DAV\CalDAV\CalDavBackend->{closure:...}()
#2 apps/dav/lib/CalDAV/CalDavBackend.php(1564): OCA\DAV\CalDAV\CalDavBackend->atomic()
#3 apps/dav/lib/CalDAV/Federation/FederatedCalendarSyncService.php(122): OCA\DAV\CalDAV\CalDavBackend->deleteCalendarObject()
#4 apps/dav/lib/BackgroundJob/FederatedCalendarPeriodicSyncJob.php(47): OCA\DAV\CalDAV\Federation\FederatedCalendarSyncService->syncOne()
#5 lib/public/BackgroundJob/Job.php(50): OCA\DAV\BackgroundJob\FederatedCalendarPeriodicSyncJob->run()
#6 lib/public/BackgroundJob/TimedJob.php(85): OCP\BackgroundJob\Job->start()
#7 core/Service/CronService.php(176): OCP\BackgroundJob\TimedJob->start()
#8 core/Service/CronService.php(98): OC\Core\Service\CronService->runCli()
#9 cron.php(52): OC\Core\Service\CronService->run()
Diagnosis
This does not appear to be orphaned subscription data in the database. On the affected instance:
calendarobjects grouped by calendartype:
calendartype=0 count=564
calendartype=2 count=1210
orphan cached subscription objects:
calendartype=1 objects without calendarsubscriptions row = 0
federated calendars:
2 rows in oc_calendars_federated
The error path is therefore the federated delete branch being routed into the cached-subscription event branch.
createCalendarObject() and updateCalendarObject() already distinguish the three cases:
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
...
} elseif ($calendarType === self::CALENDAR_TYPE_SUBSCRIPTION) {
...
} elseif ($calendarType === self::CALENDAR_TYPE_FEDERATED) {
// TODO: implement custom event for federated calendars
}deleteCalendarObject() appears to need the same structure.
Suggested fix
Change the delete branch from else to elseif ($calendarType === self::CALENDAR_TYPE_SUBSCRIPTION), and add an explicit no-op CALENDAR_TYPE_FEDERATED branch until there is a dedicated federated-calendar deleted event:
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
$calendarRow = $this->getCalendarById($calendarId);
$shares = $this->getShares($calendarId);
$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent($calendarId, $calendarRow, $shares, $data));
} elseif ($calendarType === self::CALENDAR_TYPE_SUBSCRIPTION) {
$subscriptionRow = $this->getSubscriptionById($calendarId);
$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent($calendarId, $subscriptionRow, [], $data));
} elseif ($calendarType === self::CALENDAR_TYPE_FEDERATED) {
// TODO: implement custom event for federated calendars
}I tested that local change on the affected instance by forcing the previously failing job with:
occ background-job:execute --force-execute <job-id>After the local patch, the job completed, the federated sync token advanced, and cached federated objects dropped from 1210 to 1200, indicating that the remote deletions were processed.
Server configuration
- Nextcloud version:
33.0.5.1/ version string33.0.5 - Database: PostgreSQL
- Background jobs: cron
- App/code path involved:
apps/dav/lib/CalDAV/CalDavBackend.php,apps/dav/lib/CalDAV/Federation/FederatedCalendarSyncService.php,apps/dav/lib/BackgroundJob/FederatedCalendarPeriodicSyncJob.php
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriaged
Activity
ricokulzk-dotcom commentedon Nov 21, 2026
Thank you for reporting this issue.
I can confirm that the same error still occurs on my Nextcloud 35 installation.
Environment:
Recurring error:
The error occurs repeatedly, approximately every 65 minutes.
Investigation:
I inspected the installed Nextcloud source code and confirmed the following:
In
CalDavBackend.php:In
deleteCalendarObject(), the current implementation distinguishes only between regular calendars and all other calendar types:This means that federated calendar objects (
CALENDAR_TYPE_FEDERATED = 2) also enter the subscription-specific branch.However,
getSubscriptionById()returnsnullwhen no matching subscription exists.I also confirmed that
SyncService.phpexplicitly calls:Therefore, deleting a federated calendar object can result in the observed TypeError because the code attempts to retrieve subscription data for a federated calendar.
Database findings:
The
oc_calendarsubscriptionstable contains one subscription (ID 1).The
oc_calendarobjectstable contains:calendartype = 0calendartype = 1calendartype = 2, associated with calendar ID 4No orphaned subscription objects were found in the database.
Conclusion:
The source code confirms a problematic deletion path for federated calendar objects, consistent with the recurring TypeError. I have not yet conclusively established which scheduled execution triggers each logged occurrence.
It appears that
deleteCalendarObject()needs to distinguish federated calendar objects from subscription objects rather than handling both through the same subscription-specific branch.No application code or database records have been modified during this investigation.
I hope these additional findings help confirm and resolve the issue for Nextcloud 35.
Best regards!