Skip to content

HTTP 500 when converting Meeting Proposal to Event: SQL Unique Constraint Violation on UID #7941

@shbb-asdea

Description

@shbb-asdea

Steps to reproduce

Create a new Meeting Proposal (Poll) in the Calendar web interface.

Add participants and dates.

Have a participant (or yourself) vote for a date.

Open the proposal as the owner.

Click the "Create" (or "Crea") button on the confirmed date to finalize the meeting.

Expected behavior

The "Meeting Proposal" (draft) should be deleted/converted, and a new "Event" should be created in the calendar with the details from the proposal.

Actual behavior

The UI shows a loading spinner that eventually stops or fails. The browser console shows a 500 Internal Server Error on the POST /apps/calendar/v1/proposal/convert (or similar endpoint). The backend logs show a SQLSTATE[23505]: Unique violation error regarding calobjects_by_uid_index.

Calendar app version

6.1.5

CalDAV-clients used

N/A (Issue occurs in Nextcloud Web Interface)

Browser

Firefox 147.0 (but issue is server-side)

Client operating system

Ubuntu Linux (but issue is server-side)

Server operating system

Linux (Docker Container)

Web server

Other

Database engine version

PostgreSQL

PHP engine version

PHP 8.4

Nextcloud version

32.0.3

Updated from an older installed version or fresh install

Fresh install

List of activated apps

- calendar: 6.1.5
- calendar_resource_management: 0.11.0
- spreed: (enabled, version unknown from provided snippet but active)
...and others standard for Docker image

Nextcloud configuration

Standard Docker configuration.

Web server error log

192.168.1.33 - - [30/Jan/2026:11:40:15 +0000] "POST /ocs/v2.php/calendar/proposal/convert HTTP/1.1" 500 823 "-" "Mozilla/5.0 ..."

Log file

{
  "reqId": "...",
  "level": 3,
  "time": "2026-01-30T11:40:15+00:00",
  "remoteAddr": "...",
  "user": "boris.shestakov",
  "app": "index",
  "method": "POST",
  "url": "/ocs/v2.php/calendar/proposal/convert",
  "message": "An exception occurred while executing a query: SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint \"calobjects_by_uid_index\"\nDETAIL:  Key (calendarid, calendartype, uid)=(30, 0, 9d8aa045-d371-49c1-9f70-xxxx) already exists.",
  "exception": {
    "Exception": "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException",
    "Message": "An exception occurred while executing a query: SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint \"calobjects_by_uid_index\"...",
    "File": "/var/www/html/lib/private/DB/Exceptions/DbalException.php",
    "Line": 56
  }
}

Browser log

XHR POST https://nextcloud.hippohub.lol/ocs/v2.php/calendar/proposal/convert [HTTP/2 500  1352ms]

Additional info

Root Cause Analysis: I investigated the source code in custom_apps/calendar/lib/Service/Proposal/ProposalService.php.

The error occurs because the application attempts to insert the new Event using the same UID as the existing Proposal object before the Proposal is deleted. Since both objects reside in the same database table (oc_calendarobjects) and share the same uniqueness constraint scope (calendar_id + uid), the database blocks the INSERT operation.

In convertProposal method:

The code explicitly attempts to reuse the Proposal's UUID:

// Line ~341 in ProposalService.php $vEvent->UID->setValue($proposal->getUuid() ?? Uuid::v4()->toRfc4122());

The code attempts to persist the new Event (INSERT):

// Line ~372 $userCalendar->createFromString(..., $vObject->serialize());

The code attempts to delete the old Proposal (DELETE):

// Line ~378 $this->proposalVoteMapper->deleteByProposalId(...);

Because step 2 fails with a Unique Constraint Violation, step 3 is never reached.

Temporary Workaround / Proposed Fix: I was able to resolve this by patching ProposalService.php to force the generation of a new UUID for the converted event. This avoids the database collision.

Patch applied:

`
// custom_apps/calendar/lib/Service/Proposal/ProposalService.php

// BEFORE:
// $vEvent->UID->setValue($proposal->getUuid() ?? Uuid::v4()->toRfc4122());

// AFTER (Fix):
$vEvent->UID->setValue(Uuid::v4()->toRfc4122());
`

While reusing the UID is preferred for iCal threading consistency, the current "Insert-then-Delete" logic is incompatible with strict DB constraints when the UID is already taken by the source object. Generating a new UID resolves the crash and ensures data safety (no risk of deleting the proposal if the insert fails).

Metadata

Metadata

Labels

Type

No fields configured for Bug.

Projects

Status
☑️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions