[GH-ISSUE #456] System.DevideByZeroException: Attempted to devide by zero #442

Open
opened 2026-02-25 20:31:40 +03:00 by kerem · 0 comments
Owner

Originally created by @Zenith-Mx on GitHub (Sep 16, 2025).
Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/456

When trying to synchronize Outlook events to Nextcloud via CalDavSynchronizer, one event caused this error which always pops up after every synchronization attempt.

Image

The issue occurs within the AddMasterEvent(IICalendar calendar) method in the CalDavSynchronizer.Implementation.Events.EventEntityManager class. I would suggest that it's the following part of the code which causes this error, since it's the only division I was able to find directly within the AddMasterEvent method:

var intervalInDays = GreatestCommonDivisor(sortedExceptionsWithDistance.Select(d => d.DistanceFromMasterInDays));

var numberOfEceptions = sortedExceptionsWithDistance.Last().DistanceFromMasterInDays / intervalInDays + 1;

It seems like it's possible that intervalInDays + 1 is equal to zero, causing a System.DevideByZeroException.

Implementing handling for this problem would be greatly appreciated, as the only way I found to fix the error popup during synchronization is to fully remove the event.

Originally created by @Zenith-Mx on GitHub (Sep 16, 2025). Original GitHub issue: https://github.com/aluxnimm/outlookcaldavsynchronizer/issues/456 When trying to synchronize Outlook events to Nextcloud via CalDavSynchronizer, one event caused this error which always pops up after every synchronization attempt. <img width="1011" height="451" alt="Image" src="https://github.com/user-attachments/assets/cd762c66-2f4a-4e2b-8bac-cda6d99bb214" /> The issue occurs within the AddMasterEvent(IICalendar calendar) method in the CalDavSynchronizer.Implementation.Events.EventEntityManager class. I would suggest that it's the following part of the code which causes this error, since it's the only division I was able to find directly within the AddMasterEvent method: _var intervalInDays = GreatestCommonDivisor(sortedExceptionsWithDistance.Select(d => d.DistanceFromMasterInDays));_ _var numberOfEceptions = sortedExceptionsWithDistance.Last().DistanceFromMasterInDays / **intervalInDays + 1**;_ It seems like it's possible that **intervalInDays + 1** is equal to zero, causing a System.DevideByZeroException. Implementing handling for this problem would be greatly appreciated, as the only way I found to fix the error popup during synchronization is to fully remove the event.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/outlookcaldavsynchronizer#442
No description provided.