aluxnimm / outlookcaldavsynchronizer

Sync Outlook with Google, SOGo, Nextcloud or any other CalDAV/CardDAV server
GNU Affero General Public License v3.0
899 stars 95 forks source link

Null reference exception at DDay.iCal.iCalTimeZoneInfo #386

Closed metal450 closed 1 year ago

metal450 commented 1 year ago

Using 4.4.0, for every sync, I'm getting the following exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DDay.iCal.iCalTimeZoneInfo.<>c__DisplayClass2.<GetObservance>b__0(IPeriod p)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at DDay.iCal.iCalTimeZoneInfo.GetObservance(IDateTime dt)
   at DDay.iCal.iCalTimeZone.GetTimeZoneObservance(IDateTime dt)
   at DDay.iCal.iCalDateTime.GetTimeZoneObservance()
   at DDay.iCal.iCalDateTime.get_UTC()
   at DDay.iCal.iCalDateTime.op_Subtraction(iCalDateTime left, IDateTime right)
   at DDay.iCal.Event.ExtrapolateTimes()
   at DDay.iCal.CalendarObject.DeserializedInternal(StreamingContext context)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at DDay.iCal.SerializationUtil.OnDeserialized(Object obj)
   at DDay.iCal.iCalParser.component(ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o)
   at DDay.iCal.iCalParser.icalbody(ISerializationContext ctx, IICalendar iCal)
   at DDay.iCal.iCalParser.icalendar(ISerializationContext ctx)
   at DDay.iCal.Serialization.iCalendar.iCalendarSerializer.Deserialize(TextReader tr)
   at CalDavSynchronizer.Implementation.CalDavRepository`1.DeserializeCalendar(String iCalData, IStringSerializer calendarSerializer)
   at CalDavSynchronizer.Implementation.CalDavRepository`1.TryDeserializeCalendar(String iCalData, IICalendar& calendar, WebResourceName uriOfCalendarForLogging, IStringSerializer calendarSerializer, ILoadEntityLogger logger)

Here's the ics:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ddaysoftware.com//NONSGML DDay.iCal 1.0//EN
BEGIN:VTIMEZONE
TZID:Turks And Caicos Standard Time
BEGIN:STANDARD
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;UNTIL=20150101T050000Z;BYDAY=1SU;BYHOUR=2;BYMINUTE=0;BYMO
 NTH=11
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:20150101T000000
RRULE:FREQ=YEARLY;UNTIL=20160101T050000Z;BYDAY=1TH;BYHOUR=0;BYMINUTE=0;BYMO
 NTH=1
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:20160102T000000
RRULE:FREQ=YEARLY;UNTIL=20170101T050000Z;BYHOUR=0;BYMINUTE=0;BYMONTH=1;BYMO
 NTHDAY=1
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:20170102T000000
RRULE:FREQ=YEARLY;UNTIL=20180101T050000Z;BYHOUR=0;BYMINUTE=0;BYMONTH=1;BYMO
 NTHDAY=1
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:20181104T020000
RRULE:FREQ=YEARLY;UNTIL=20190101T050000Z;BYDAY=1SU;BYHOUR=2;BYMINUTE=0;BYMO
 NTH=11
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:20191103T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=11
TZNAME:Turks and Caicos Standard Time
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;UNTIL=20150101T050000Z;BYDAY=2SU;BYHOUR=2;BYMINUTE=0;BYMO
 NTH=3
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20150308T020000
RRULE:FREQ=YEARLY;UNTIL=20160101T050000Z;BYDAY=2SU;BYHOUR=2;BYMINUTE=0;BYMO
 NTH=3
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20160101T000000
RRULE:FREQ=YEARLY;UNTIL=20170101T050000Z;BYHOUR=0;BYMINUTE=0;BYMONTH=1;BYMO
 NTHDAY=1
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0500
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20170101T000000
RRULE:FREQ=YEARLY;UNTIL=20180101T050000Z;BYHOUR=0;BYMINUTE=0;BYMONTH=1;BYMO
 NTHDAY=1
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0500
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20180311T020000
RRULE:FREQ=YEARLY;UNTIL=20190101T050000Z;BYDAY=2SU;BYHOUR=2;BYMINUTE=0;BYMO
 NTH=3
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20190310T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3
TZNAME:Turks and Caicos Daylight Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:040000008200E00074C5B7101A82E00800000000200C6FB26A58D901000000000000000
 0100000009DA701809DD45B4284BAD692CD904C78
DTSTART;TZID=Turks And Caicos Standard Time:20230406T010000
DTEND;TZID=Turks And Caicos Standard Time:20230406T013000
CLASS:PUBLIC
DESCRIPTION: 
DTSTAMP:20230317T045217Z
PRIORITY:5
SEQUENCE:0
SUMMARY:2023/04/06 - Make Sure I Get Sunscreen
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-PT15M
END:VALARM
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
END:VCALENDAR

Looks like this one, from back in 2016: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/107

aluxnimm commented 1 year ago

Well our icalendar libraries has issues with exotic timezone definitions in VTIMEZONE, you just need to delete and recreate that appointment with a standard windows timezone definition for that location for example and it should go away.

metal450 commented 1 year ago

If this is a known/recurring issue that won't be fixed, seems like it should at least have a clear user-facing message to that effect. It took me awhile just to notice that it was consistently failing, and then to realize that it was always the same item. Also note that I didn't explicitly choose the timezone for the reminder - I was simply traveling, and that was the default thta Outlook selected, due to Windows being on that timezone. A simple pop-up warning like "You have a calendar item that is failing to sync due to its timezone. Please delete this item & recreate with a different timezone" would no doubt save users a lot of time & confusion.