Simple-Calendar icon indicating copy to clipboard operation
Simple-Calendar copied to clipboard

Synchronization issue with 400 error on recurring events

Open NicoHood opened this issue 2 years ago • 20 comments

Hi, I get 400 errors when synching with davx5 and radicale server. I contacted the davx5 support and we debugged it really good:

The issue happens if you

  1. Create a weekly repeating event
  2. Delete a single entry of that event series
  3. sync

It generates the following (sample) entry, which if invalid and therefore rejected by the radicale server:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.0-gplay ical4j/3.1.0
BEGIN:VEVENT
DTSTAMP:20211110T085217Z
UID:2b388553-e36b-44d9-a339-5fb9816aac22
SEQUENCE:1
SUMMARY:Joggen
DTSTART;TZID=Europe/Berlin:20211104T170000
DTEND;TZID=Europe/Berlin:20211104T170000
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TH
STATUS:CONFIRMED
BEGIN:VALARM
TRIGGER:-PT30M
ACTION:DISPLAY
DESCRIPTION:Joggen
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211110T085217Z
UID:2b388553-e36b-44d9-a339-5fb9816aac22
RECURRENCE-ID;TZID=Europe/Berlin:20211118T170000
SEQUENCE:1
DTSTART;TZID=Europe/Berlin:19700120T004731
DTEND;TZID=Europe/Berlin:19700120T004731
EXDATE:20211117T230000Z
END:VEVENT
BEGIN:VTIMEZONE
TZID:Europe/Berlin
LAST-MODIFIED:20201010T011803Z
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19160430T230000
RDATE:19400401T020000
RDATE:19430329T020000
RDATE:19460414T020000
RDATE:19470406T030000
RDATE:19480418T020000
RDATE:19490410T020000
RDATE:19800406T020000
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19471005T030000
RRULE:FREQ=YEARLY;UNTIL=19491002T010000Z;BYMONTH=10;BYDAY=1SU
END:STANDARD
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19800928T030000
RRULE:FREQ=YEARLY;UNTIL=19950924T010000Z;BYMONTH=9;BYDAY=-1SU
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
END:VCALENDAR

As you can see the id is duplicated, as well as the VEVENT entry. I tested this with google calendar and it does not happen there.

Here is the response from the davx5 support, it could help you with debugging:

Thanks for your report. The public bugtracker is our forum; I have now linked it from Github issues of the davx5-ose repo to make it more clear.

I had a look at your report, with the following findings:

You're using Simple Calendar Pro, which inserts the event like this:
* main_event: data with <RRULE>
* deleted instance: another data rows of type "exception" (refers to main_event), with DTSTART and EXDATE set to the deleted instance

So DAVx5 generates

BEGIN:VEVENT
UID:event
DTSTART:…
RRULE:…
END:VEVENT
BEGIN:VEVENT
UID:event
RECURRENCE-ID:<date of exception>
DTSTART:<date of exception>
EXDATE:<date of exception>
END:VEVENT

This is invalid and thus Radicale rejects the iCalendar.

However, as I understand it and as other calendar apps, EXDATE is to be used in the main event. So for an instance, there are two methods:

1.
  * main_event: data with <RRULE> and <EXDATE>(s) for the deleted instances, or
2. 
  * main_event: data with <RRULE>
  * deleted instance: another data rows of type "exception" (refers to main_event), with DTSTART and STATUS=cancelled

So I think this is a problem of Simple Calendar. Can you please try another calendar app and tell me whether it works?

NicoHood avatar Nov 10 '21 13:11 NicoHood

what app and OS version are you using?

tibbi avatar Nov 12 '21 09:11 tibbi

Android 10 Simple Calendar (If there is a pro, it is pro) Version 6.15.4 Davx5 4.0-gplay

NicoHood avatar Nov 12 '21 09:11 NicoHood

I want to add, that the issue exists quite a long time, but I never really catched why this happens (excluding events). It is quite critical, as the whole calendar stops to sync. Do you have any first idea how to solve this?

NicoHood avatar Nov 14 '21 16:11 NicoHood

Im not sure, havent really met many people using Radicale. It seems to work just fine in the popular calendar services.

tibbi avatar Nov 14 '21 16:11 tibbi

Im not sure, havent really met many people using Radicale. It seems to work just fine in the popular calendar services.

It's not a Radicale problem. The problem comes from how exceptions are stored in the Android calendar provider.

rfc2822 avatar Nov 14 '21 18:11 rfc2822

If you need a radicale test account, I can give you some via Email. I guess that would be easier for you.

NicoHood avatar Nov 14 '21 20:11 NicoHood

Any updates on that issue? It is really blocking me, as I cannot use recurring events with an excluded event

NicoHood avatar Nov 21 '21 12:11 NicoHood

@tibbi would you please mind having another look at this issue? Sadly it makes the app (mostly) unusable for me. I guess that you as an expert will be able to solve this quite easy, I hope so. If you need I can assist with further testing!

Thanks a lot :)

NicoHood avatar Dec 02 '21 17:12 NicoHood

not really, such issues are actually difficult to reproduce and are system/setup specific, so basically edge cases

tibbi avatar Dec 02 '21 20:12 tibbi

It should be reproducible with the three easy steps from the first posting and as I understand it, it's neither related to Radicale nor to some server or system-specific property. It's about how Simple Calendar stores exceptions in the Android calendar provider; and this differs from the iCalendar and Android specifications.

rfc2822 avatar Dec 02 '21 20:12 rfc2822

Yeah, you can easily validate the ical and see, that there is a duplicated id, that violates the ical spec: https://icalendar.org/validator.html

image

If you need a radicale server to test this on, I can give you access to one. It is 100% reproducible.

NicoHood avatar Dec 03 '21 10:12 NicoHood

Any chance? 🥺🥺🥺

NicoHood avatar Dec 28 '21 19:12 NicoHood

as mentioned previously, it isnt a priority for now as it is an edge case not happening often. There are more important issues too.

tibbi avatar Dec 28 '21 22:12 tibbi

Any updates on this issue? I also encountered this problem.

LorenzBischof avatar Mar 31 '22 12:03 LorenzBischof

This issue is a client issue. I can reproduce when editing a single occurrence of a recurring event.

The problem there is the RECURRENCE-ID cannot be the same as the previous entry. The client leaves it as is which results in a 400 error as it must not already exist.

Error returned to the client: Bad PUT request ... Overwritten recurrence with RRULESET

For reference: https://www.rfc-editor.org/rfc/rfc5545, section 3.8.4.4.

ghost avatar Mar 31 '22 15:03 ghost

Hi there.

I've run into this too. I also asked DAVx5 for help and they were very nice about it but they sent me here. Here's the relevant parts of my bug report there:

SimpleCalendar doesn't show anything weird:

simplecalendar-ui

But internally it's generated this bad event:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.2.1-ose ical4j/3.1.2 (com.simplemobiletools.calendar.pro)
BEGIN:VEVENT
DTSTAMP:20220627T020021Z
UID:44fe7d67-516b-4ada-94d9-48095dc71c71
SEQUENCE:1
SUMMARY:Data R&D
DTSTART;TZID=America/Toronto:20220503T140000
DTEND;TZID=America/Toronto:20220503T150000
RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=1;BYDAY=TU
STATUS:CONFIRMED
ORGANIZER:mailto:[email protected]
ATTENDEE;RSVP=TRUE;CN=Nick;PARTSTAT=ACCEPTED:mailto:[email protected]
ATTENDEE;RSVP=TRUE;CUTYPE=UNKNOWN;PARTSTAT=NEEDS-ACTION:mailto:mathieu
BEGIN:VALARM
TRIGGER:-PT1H30M
ACTION:DISPLAY
DESCRIPTION:Data R&D
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20220627T020021Z
UID:44fe7d67-516b-4ada-94d9-48095dc71c71
RECURRENCE-ID;TZID=America/Toronto:20220517T140000
SEQUENCE:1
DTSTART;TZID=America/Toronto:19700119T220650
DTEND;TZID=America/Toronto:19700119T220654
EXDATE:20220517T040000Z
ORGANIZER:mailto:[email protected]
END:VEVENT
BEGIN:VTIMEZONE
TZID:America/Toronto
LAST-MODIFIED:20201010T011803Z
BEGIN:DAYLIGHT
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
DTSTART:19500430T020000
RRULE:FREQ=YEARLY;UNTIL=19860427T070000Z;BYMONTH=4;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
DTSTART:19571027T020000
RRULE:FREQ=YEARLY;UNTIL=20061029T060000Z;BYMONTH=10;BYDAY=-1SU
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
DTSTART:19870405T020000
RRULE:FREQ=YEARLY;UNTIL=20060402T070000Z;BYMONTH=4;BYDAY=1SU
END:DAYLIGHT
BEGIN:DAYLIGHT
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
END:VCALENDAR

Here's the exception that Radicale throws:



[2022-06-27 03:07:52 +0200] [88918/Thread-488] [WARNING] Bad PUT request on '/kousu/49e46e0e-9a17-a205-088b-ad61d3326b99/44fe7d67-516b-4ada-94d9-48095dc71c71.ics': Overwritten recurrence with RRULESET
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/radicale/app/put.py", line 95, in prepare
    item.prepare()
  File "/usr/local/lib/python3.8/site-packages/radicale/item/__init__.py", line 470, in prepare
    self.time_range
  File "/usr/local/lib/python3.8/site-packages/radicale/item/__init__.py", line 459, in time_range
    self._time_range = find_time_range(
  File "/usr/local/lib/python3.8/site-packages/radicale/item/__init__.py", line 324, in find_time_range
    radicale_filter.visit_time_ranges(vobject_item, tag, range_fn, infinity_fn)
  File "/usr/local/lib/python3.8/site-packages/radicale/item/filter.py", line 246, in visit_time_ranges
    for child, is_recurrence, recurrences in get_children(
  File "/usr/local/lib/python3.8/site-packages/radicale/item/filter.py", line 234, in get_children
    raise ValueError("Overwritten recurrence with RRULESET")
ValueError: Overwritten recurrence with RRULESET

and for reference, the code that's crashing is https://github.com/Kozea/Radicale/blob/497b5141b066d266c318ea2cd021980e1b21a516/radicale/item/filter.py#L229-L234.

This is a pretty big thorn for me, it means when it happens I get

davx5-error-notif

and that error persists for as long as the bad event exists. It blocks syncing of all events, and I start forgetting what I've signed up for :sweat: The only way to clear it is to delete the event entirely -- but I don't want to do that because I've been deleting parts of the recurrence to record what weeks it actually happens, so I can work out for later when I was working or not.

kousu avatar Jun 29 '22 13:06 kousu

I have encountered the problem as well, using Simple-Calendar and Radicale.

tobse1211 avatar Aug 13 '22 20:08 tobse1211

Problem encountered here as well.

Simple Calendar 6.19.0 PRO DAVx5 4.2.2-ose

clementefnc avatar Aug 23 '22 11:08 clementefnc

@tibbi Arent enough people affected now? Even more who did not find this github issue would also have this issue. It is a very common usecase.

NicoHood avatar Aug 23 '22 13:08 NicoHood

imo I don't see how this is a edge case. For me (and obviously other people as well) this is a very common usecase. I even have a second calendar app (Etar) installed for the sole purpose of removing a single occurrence of a reoccurring event.

I'd very much appreciate if you'd have a look into this @tibbi

reedts avatar Aug 24 '22 06:08 reedts

I am having the same issue. For now I removed Simple-Calendar and installed Etar. However, the error persists. I think I have to delete the bad event. But I don't know how to do so. Can anyone help?

[EDIT:] Found help here: https://www.davx5.com/faq/recurring-events After deleting the suspicious events I deleted my account in DAVx5 and re-created it.

lmoellendorf avatar Nov 02 '22 12:11 lmoellendorf

I was able to delete the bad event with SimpleCalendar.

kousu avatar Nov 02 '22 13:11 kousu

I had the same issue and switched to Etar for now.

gabriel-berardi avatar Dec 22 '22 10:12 gabriel-berardi

@tibbi How shall we count the number of people affected? Adding thumbs up to @reedts 's comment above? Just adding comments for "Me too" does not really improve things. I'll vote above and say that I'm affected here, as well, for now :)

tbart avatar Dec 27 '22 18:12 tbart

well Im aware of the issue, but if I cannot reproduce it in any way, it is hard to fix

tibbi avatar Dec 28 '22 09:12 tibbi

Well you should be able to reproduce this 100% with the steps in the first post. With radicale and davx5 the issue will occur 100%. Maybe with other servers as well, but those are the ones I've tested

NicoHood avatar Dec 28 '22 09:12 NicoHood

To sum things up

  1. This does not really seem to be backend specific. 1b) Even if it is, @NicoHood offered access to a radicale instance, so no setup overhead involved for reproduction. @NicoHood: Can you probably give @tibbi access details already?
  2. There seems to be a specification violation as pointed out by NicoHood above, so that sounds like it should be fixed anyway (and it will most probably fix the resulting issue with (at least) radicale as well). There might be other implementations that are more forgiving, but this should not be relied upon.
  3. I'll give my 2c for how I can trigger it in a few seconds:
  • Add repeating event (trash collection, every 6 weeks in my case)
  • Edit one event of those and shift just this event by one day (very similar to OP's deletion of one event)
  • Sync & get "Bad request" (or Patrick West as I call it :) )

I don't want to seem pushy, I am just a sysadmin so I cannot help with Java coding. I am absolutely willing to test or help in other ways I can!

tbart avatar Dec 28 '22 13:12 tbart

Hi guys,

I recently switched from a nextcloud instance to using mailbox.org and I started getting the same error, so +1 to affected people and probably anyone with a mailbox account. I can provide any further info if needed.

rekesz4 avatar Jan 23 '23 18:01 rekesz4

+1 but to solve the issue all you need to do is to delete the problematic recurring events one by one by one using the 'view item' within the error notification produced by davx5. (And in the future refrain from modifying recurring events too much with simple calendar until the error is fixed..)

tnar-git avatar Feb 10 '23 05:02 tnar-git

This one bites me everytime I remove an occurrence of a recurring event, and I always forget there's this issue before it's too late... The resolution is quite painful.

Here are some references for this bug on Radicale and Davx5 projects. https://github.com/bitfireAT/davx5-ose/discussions/66 https://github.com/Kozea/Radicale/issues/1264

Could you please reconsider having a look at this? I could provide an account on my radicale server for testing purposes.

Thank you

kot0dama avatar Feb 23 '23 08:02 kot0dama