Skip to content

Commit 916ef6d

Browse files
tobixenclaude
andcommitted
test: fix Nextcloud 33 test failures caused by trashbin UID conflicts
Nextcloud 33 introduced (or changed) soft-delete behaviour: when a calendar is deleted via CalDAV, both the calendar and its objects are soft-deleted to a trashbin. When tests delete and re-create a calendar with the same slug, Nextcloud reuses the same calendarid, and the soft-deleted objects (with their UIDs) remain in oc_calendarobjects. Trying to add a new event with the same UID then fails with "UNIQUE constraint failed: calendarid, calendartype, uid". Fix: set calendarRetentionObligation=0 in setup_nextcloud.sh. When this config value is the string '0', CalDavBackend::deleteCalendar and deleteCalendarObject skip the trashbin entirely and hard-delete immediately (see apps/dav/lib/CalDAV/CalDavBackend.php lines 940-941, 1572). Also run dav:retention:clean-up at startup to purge any leftover soft-deleted entries from prior runs. Also update the nextcloud compatibility hints to reflect the changed behaviour of scheduling.mailbox.inbox-delivery in Nextcloud 33: the server now delivers the iTIP notification to the inbox AND auto-schedules into the attendee's calendar (quirk), whereas previously it only delivered to the inbox (full). Prompt: `pytest -k nextcloud --last-failed` gives lots of failures. It seems to be something wrong with the nextcloud container. Looks a bit like the problems are due to the setup (user provisioning) is not being compatible with the latest version of the image. Please investigate. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 42ea7fe commit 916ef6d

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

caldav/compatibility_hints.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,10 @@ def dotted_feature_set_list(self, compact=False):
945945
'principal-search': {'support': 'ungraceful'},
946946
#'old_flags': ['unique_calendar_ids'],
947947
## I'm surprised, I'm quite sure this was passing earlier. Caldav commit a98d50490b872e9b9d8e93e2e401c936ad193003, caldav server checker commit 3cae24cf99da1702b851b5a74a9b88c8e5317dad
948-
'search.combined-is-logical-and': False
948+
'search.combined-is-logical-and': False,
949+
## Observed with Nextcloud 33: server delivers iTIP notification to the inbox AND
950+
## auto-schedules into the attendee's calendar (same quirk as Baikal/Cyrus).
951+
"scheduling.mailbox.inbox-delivery": {"support": "quirk", "behaviour": "server delivers iTIP notification to inbox AND auto-schedules into calendar"},
949952
}
950953

951954
## TODO: Latest - mismatch between config and test script in delete-calendar.free-namespace ... and create-calendar.set-displayname?

tests/docker-test-servers/nextcloud/setup_nextcloud.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ fi
6161
docker exec $CONTAINER_NAME php occ app:disable bruteforcesettings || true
6262
docker exec $CONTAINER_NAME php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean || true
6363

64+
echo "Disabling CalDAV trashbin (calendar retention)..."
65+
# Setting calendarRetentionObligation to '0' (the string) disables the trashbin in
66+
# CalDavBackend::deleteCalendar and deleteCalendarObject, making deletes permanent.
67+
# Without this, deleted calendars/objects are soft-deleted and accumulate in the DB,
68+
# causing UNIQUE constraint violations when tests recreate a calendar with the same slug
69+
# (Nextcloud 33+ reuses the calendarid, keeping old soft-deleted objects, so adding
70+
# an event with the same UID fails).
71+
docker exec $CONTAINER_NAME php occ config:app:set dav calendarRetentionObligation --value=0 || true
72+
# Purge any leftover soft-deleted calendars/objects from previous runs
73+
docker exec $CONTAINER_NAME php occ dav:retention:clean-up || true
74+
6475
echo "Configuring CalDAV rate limits..."
6576
docker exec $CONTAINER_NAME php occ config:app:set dav rateLimitCalendarCreation --value=99999 || true
6677
docker exec $CONTAINER_NAME php occ config:app:set dav maximumCalendarsSubscriptions --value=-1 || true

0 commit comments

Comments
 (0)