[PR #1116] [MERGED] Fix CalDAV REPORT request to properly respond with VTODO objects #4713

Closed
opened 2026-04-16 13:13:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1116
Author: @v-yarotsky
Created: 7/14/2025
Status: Merged
Merged: 7/14/2025
Merged by: @kolaente

Base: mainHead: vy-fix-caldav-report-pr


📝 Commits (3)

📊 Changes

2 files changed (+77 additions, -1 deletions)

View changed files

📝 pkg/routes/caldav/listStorageProvider.go (+1 -1)
📝 pkg/webtests/caldav_test.go (+76 -0)

📄 Description

First off, thanks for this awesome project!

Currently, when the following request is made:

<?xml version="1.0" encoding="utf-8"?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
  <D:prop>
    <C:calendar-data/>
  </D:prop>
  <C:filter>
    <C:comp-filter name="VCALENDAR">
      <C:comp-filter name="VTODO">
      </C:comp-filter>
    </C:comp-filter>
  </C:filter>
</C:calendar-query>

Vikunja responds with

<?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/">
  <D:response>
    <D:href>/dav/projects/1/6cbf88d0-1129-438e-a1a3-5b9c1f92bd96.ics</D:href>
    <D:propstat>
      <D:prop>
        <C:calendar-data>BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
X-PUBLISHED-TTL:PT4H
X-WR-CALNAME:
PRODID:-//Vikunja Todo App//EN
END:VCALENDAR</C:calendar-data>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <D:response>
    ...
  </D:response>
</D:multistatus>  

As you can see, it does not include the VTODO element.
I've stumbled upon this when integrating Vikunja with Home Assistant via their CalDAV integration.
When marking an item as completed via Home Assistant, I saw an error:

Failed to perform the action todo/update_item. 'CalendarObjectResource' object has no attribute 'set_due'

This has been filed as a bug with Home Assistant previously: https://github.com/home-assistant/core/issues/122346.

As it turned out, they fetch the TODO item before updating it. Because the response doesn't include the actual VTODO, the library used by Home Assistant fails to unmarshal the response properly, resulting in the aforementioned error.

With this change, Vikunja will actually include the VTODO in the response, fixing the issue.
This should also be consistent with the spec. I've followed the example from RFC 4791 Section 7.8.9.

Updated response example:

<?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/">
  <D:response>
    <D:href>/dav/projects/1/6cbf88d0-1129-438e-a1a3-5b9c1f92bd96.ics</D:href>
    <D:propstat>
      <D:prop>
        <C:calendar-data>BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
X-PUBLISHED-TTL:PT4H
X-WR-CALNAME:
PRODID:-//Vikunja Todo App//EN
BEGIN:VTODO
UID:6cbf88d0-1129-438e-a1a3-5b9c1f92bd96
DTSTAMP:20250708T063859Z
SUMMARY:Put out bins – Garbage/Compost
COMPLETED:20250708T063859Z
STATUS:COMPLETED
DUE:20250722T040000Z
CREATED:20250707T021855Z
PRIORITY:3
RRULE:FREQ=SECONDLY;INTERVAL=1209600
LAST-MODIFIED:20250708T063859Z
END:VTODO
END:VCALENDAR</C:calendar-data>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <D:response>
    ...
  </D:response>
</D:multistatus>  

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/1116 **Author:** [@v-yarotsky](https://github.com/v-yarotsky) **Created:** 7/14/2025 **Status:** ✅ Merged **Merged:** 7/14/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `vy-fix-caldav-report-pr` --- ### 📝 Commits (3) - [`e069127`](https://github.com/go-vikunja/vikunja/commit/e0691277127aa4fc46eecf5598c8fa1c3b56c9c9) Add a failing test - [`a21fd8b`](https://github.com/go-vikunja/vikunja/commit/a21fd8b06bbf0e9b2d91255f562373a2e33d7296) Fix the test - [`e97a108`](https://github.com/go-vikunja/vikunja/commit/e97a1083b8f1bcc3c8fda21159d6c7eaccd4903a) Fix lint failure & rename the test ### 📊 Changes **2 files changed** (+77 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `pkg/routes/caldav/listStorageProvider.go` (+1 -1) 📝 `pkg/webtests/caldav_test.go` (+76 -0) </details> ### 📄 Description First off, thanks for this awesome project! Currently, when the following request is made: ```xml <?xml version="1.0" encoding="utf-8"?> <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> <D:prop> <C:calendar-data/> </D:prop> <C:filter> <C:comp-filter name="VCALENDAR"> <C:comp-filter name="VTODO"> </C:comp-filter> </C:comp-filter> </C:filter> </C:calendar-query> ``` Vikunja responds with ```xml <?xml version="1.0" encoding="UTF-8"?> <D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/"> <D:response> <D:href>/dav/projects/1/6cbf88d0-1129-438e-a1a3-5b9c1f92bd96.ics</D:href> <D:propstat> <D:prop> <C:calendar-data>BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH X-PUBLISHED-TTL:PT4H X-WR-CALNAME: PRODID:-//Vikunja Todo App//EN END:VCALENDAR</C:calendar-data> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> <D:response> ... </D:response> </D:multistatus> ``` As you can see, it does not include the `VTODO` element. I've stumbled upon this when integrating Vikunja with Home Assistant via their [CalDAV integration](https://www.home-assistant.io/integrations/caldav/). When marking an item as completed via Home Assistant, I saw an error: ``` Failed to perform the action todo/update_item. 'CalendarObjectResource' object has no attribute 'set_due' ``` This has been filed as a bug with Home Assistant previously: https://github.com/home-assistant/core/issues/122346. As it turned out, they [fetch the TODO item]( https://github.com/home-assistant/core/blob/bc07030304581d7529f0fe49a7f5ac33d2e864d5/homeassistant/components/caldav/todo.py#L151) before updating it. Because the response doesn't include the actual `VTODO`, the library used by Home Assistant fails to unmarshal the response properly, resulting in the aforementioned error. With this change, Vikunja will actually include the `VTODO` in the response, fixing the issue. This should also be consistent with the spec. I've followed the example from [RFC 4791 Section 7.8.9](https://datatracker.ietf.org/doc/html/rfc4791#section-7.8.9). Updated response example: ```xml <?xml version="1.0" encoding="UTF-8"?> <D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:CS="http://calendarserver.org/ns/"> <D:response> <D:href>/dav/projects/1/6cbf88d0-1129-438e-a1a3-5b9c1f92bd96.ics</D:href> <D:propstat> <D:prop> <C:calendar-data>BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH X-PUBLISHED-TTL:PT4H X-WR-CALNAME: PRODID:-//Vikunja Todo App//EN BEGIN:VTODO UID:6cbf88d0-1129-438e-a1a3-5b9c1f92bd96 DTSTAMP:20250708T063859Z SUMMARY:Put out bins – Garbage/Compost COMPLETED:20250708T063859Z STATUS:COMPLETED DUE:20250722T040000Z CREATED:20250707T021855Z PRIORITY:3 RRULE:FREQ=SECONDLY;INTERVAL=1209600 LAST-MODIFIED:20250708T063859Z END:VTODO END:VCALENDAR</C:calendar-data> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> <D:response> ... </D:response> </D:multistatus> ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 13:13:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#4713