todoman icon indicating copy to clipboard operation
todoman copied to clipboard

Expected datetime, date, or time, got: '%s'" % ical

Open Konfekt opened this issue 6 years ago • 8 comments

On the master branch, commit https://github.com/pimutils/todoman/commit/f2a006b2b057a33c6d06cafb7e4ab9ba7c61d8c2, todo list gives

Failed to read entry /home/konfekt/.local/share/vdirsyncer/todo/Todo4182454.ics.
Traceback (most recent call last):
  File "/home/konfekt/.local/lib/python3.6/site-packages/todoman/model.py", line 954, in update_cache
    cal = icalendar.Calendar.from_ical(cal)
  File "/home/konfekt/.local/lib/python3.6/site-packages/icalendar/cal.py", line 383, in from_ical
    vals = factory(factory.from_ical(vals))
  File "/home/konfekt/.local/lib/python3.6/site-packages/icalendar/prop.py", line 348, in from_ical
    "Expected datetime, date, or time, got: '%s'" % ical
ValueError: Expected datetime, date, or time, got: ''

as soon as the ics file contains the three empty entries

DTSTART:
STATUS:
COMPLETED:

Unfortunately, the Android applications aCalendar Tasks and OpenTasks both generate these empty fields by default.

Konfekt avatar Nov 19 '18 23:11 Konfekt

Deleting these three empty entries manually resolves the error. Could todoman ignore these empty entries instead of throwing the error?

Konfekt avatar Nov 19 '18 23:11 Konfekt

Looks like empty values for these fields are not valid (as per RFC5545).

If I have the time, I might work around accepting these invalid values, however, you should report this to these Android tasks, since they're generating what seems to be, invalid iCalendar files.

WhyNotHugo avatar Nov 20 '18 18:11 WhyNotHugo

Okay, reported to CalDav-Sync. Still, does not hurt to accept these from a user's perspective who does not have strong opinions on whether an empty date counts as a date.

Konfekt avatar Nov 20 '18 19:11 Konfekt

This issue has just been brought to my attention and I've tried to reproduce this immediately. So far I have not been successful. @Konfekt can you give me the exact steps to create such a broken ics file with OpenTasks and CalDAV-Sync? When I create a simple task with a due date in OpenTasks this gets uploaded to my server:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//dmfs.org//mimedir.icalendar//EN
BEGIN:VTODO
DUE:20181121T230000Z
CREATED:20181121T224931Z
LAST-MODIFIED:20181121T224931Z
SUMMARY:test123
STATUS:NEEDS-ACTION
DTSTAMP:20181121T224932Z
UID:21fb24f7-1bf4-4748-b257-7f437ab326fe.1542840572545
END:VTODO
END:VCALENDAR

That looks correct to me. What kind of CalDAV server are you using? Are there any other tools involved? Can you post a full ics that was uploaded to your server by CalDAV-Sync?

I'd advise against accepting broken input. Being fault tolerant only leads to faulty software. It's good to reject broken data and reach out to the creator of it.

dmfs avatar Nov 21 '18 23:11 dmfs

It is the sync.memotoo.com server. No tools other than Open Tasks and CalDAV-Sync. I added a Task with name Task due the day after tomorrow. Then synced on Android and on Linux by vdirsyncer sync. The file memotooTodo4184174.ics that appears on Linux reads

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTODO
UID:memotooTodo4184174
SUMMARY:Test
DESCRIPTION:
DTSTART:
DUE:20181124T010000Z
PRIORITY:5
STATUS:
COMPLETED:
PERCENT-COMPLETE:0
CLASS:PRIVATE
DTSTAMP:20181122T002103Z
LAST-MODIFIED:20181122T002103Z
END:VTODO
END:VCALENDAR

Seemingly, this can be remedied by running an akonadi daemon by making Korganizer watch the vdirsyncer directory, and changes the entries to an acceptable format.

Konfekt avatar Nov 22 '18 00:11 Konfekt

Looks like a Memotoo issue. Aside from the empty fields, there is another issue with this. A CalDAV server is not supposed to change file name nor UID of the object, but Memotoo clearly changed the UID. Also the PRODID field has been removed. This may well be the reason for why the other direction doesn't work either. I imported your ics file onto my server and it was synced without any problem. I'll try to reactivate my Memotoo account and test it.

dmfs avatar Nov 22 '18 21:11 dmfs

Thank you, yes, it would be good to know which servers do not invalidate the uploaded ICS files.

Konfekt avatar Nov 23 '18 11:11 Konfekt

Most other servers don't. Check out fruux.com for instance.

dmfs avatar Nov 23 '18 12:11 dmfs