derekantrican / GAS-ICS-Sync

A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
GNU General Public License v3.0
1.54k stars 197 forks source link

Automatically repair incorrectly formatted ics files from Microsoft #386

Closed rupumped closed 10 months ago

rupumped commented 10 months ago

Microsoft Outlook has a bug that sometimes results in incorrectly formatted ics files:

If unfixed, this error will result in fetchSourceCalendars() returning with error [ERROR] Incorrect ics/ical URL: followed by the URL of the broken ics.

After I noticed the bug, I confirmed it on a call with Microsoft support. The support agent told me it would likely take months to fix.

This tries to fix that problem by adding END:VEVENT after every VEvent and adding an END:VCALENDAR at the end of the file if the original regex match fails. to find END:VCALENDAR.

derekantrican commented 10 months ago

@rupumped Sorry to hear that! You said you "confirmed it on a call with Microsoft support"? How did you confirm it? Were you able to nail down what situations seem to cause it?

derekantrican commented 10 months ago

@rupumped Also - do you have any open tickets with Microsoft related to issue that I can follow?

derekantrican commented 10 months ago

@jonas0b1011001 I don't have time to think through these changes right now. Do they seem fine to you or do you have any suggestions?

rupumped commented 10 months ago

@derekantrican My request was assigned a case and tracking ID number 2312060050002441 by the support agent, Vikash Kumar, but it was handled entirely by phone, email, and Quick Assist. We met a few times to confirm the bug, including manually inspecting the ics file, unpublishing and republishing the calendar, and creating a copied user account. I asked Vikash for documentation and updates on the case, but he expressed that no such public record would exist; the case would be handled exclusively internally by Microsoft. We could not identify a particular pattern that caused the error. Interestingly, initiating an asynchronous mailbox move temporarily fixed the problem. To me, this suggests that the situation that causes the bug may not be directly related to anything about the user account publishing the calendar.

@jonas0b1011001 that is a good question, and I don't know the answer. I don't have a lot of test cases on which to experiment. In the couple that I managed to create, there was only one instance of END:VEVENT, both times at the end of the ics file.

derekantrican commented 10 months ago

assigned a case and tracking ID number 2312060050002441

Is that the only sort of "id" or link that you have? Anything else that might identify it?

(I don't know if you're aware, but I work at Microsoft and I'm hoping I can surface this issue internally as it might be a big problem)

rupumped commented 10 months ago

@derekantrican, in the confirmation email, the incident had the title I had given it, "Bug in Outlook Calendar ICS Export" with a severity rating of "C." I didn't know you worked at Microsoft; that's pretty convenient. If you want, shoot me an email at nicholas.selby@renewvia.com, and I can send you my email correspondence with Vikash or any other information you might find useful.

Obviously, y'all should do whatever you think is best here. Kucladell's solution in #388 seems quite similar to mine in that it tries to add END:VEVENT at the end of every event, and then finishes by appending END:VCALENDAR to the end of the file. I'd rather not broadcast my work calendar details to the internet, but I can privately send you my problematic ICS if you want to play around with it yourself. For what it's worth, I did test and am currently using my PR solution in my Google Apps Scripts, and it works.

@jonas0b1011001, I replaced my L88 with your code block, and it also works. Personally, I like your solution better than mine, and I encourage you to use it instead.

Kucladell commented 10 months ago

@jonas0b1011001 I tested the code by @rupumped with the L88 proposal of yours, and the code seems to work fine in my environment as well. I find this solution more elegant as it avoids making a large variable that contains the entirety of the ICS file just to fix this issue. Hopefully I can improve my skills to one day come up with a code as refined as this.

Fabrolly commented 10 months ago

Also for me this solution works. Thanks

elbeshenrique commented 10 months ago

@jonas0b1011001 also tested and works for me, thank you!

rupumped commented 10 months ago

Given the successful tests, I've added @jonas0b1011001's solution to this PR. @derekantrican, I think it's ready for merge whenever you're comfortable.

loicpavard commented 10 months ago

Great job. Replacing existing function fetchSourceCalendars(sourceCalendarURLs) within Helper.gs, by the above function code, did solve the issue for me as well. Thanks guys

rienheuver commented 10 months ago

Just wanted to mention that this solved my issue with it as well. So thanks for your work!

yermulnik commented 10 months ago

Not sure which solution fixed missing Outlook calendar events in my Google calendar since I copied over both: this and https://github.com/derekantrican/GAS-ICS-Sync/pull/343 — not matter which, I'd like to thank both contributors! Thank you!