Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip on 5xx and 4xx URL errors #392

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ function startSync(){

//------------------------ Fetch URL items ------------------------
var responses = fetchSourceCalendars(sourceCalendarURLs);
//Skip the source calendar if a 5xx or 4xx error is returned. This prevents deleting all of the existing entries if the URL call fails.
if (responses.length == 0){
Logger.log("Error Syncing " + sourceCalendarName + ". Skipping...");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm uncomfortable with this solution. Instead of a conspicuously missing calendar, we end up with a wrong calendar that appears to be correct (because it is merely outdated).

See discussion in #343 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@octogonz I agree that having a stale calendar isn't great, but I don't want to miss meetings/events because they are absent from my calendar. In the issue thread, it sounds like you are on the path toward a good solution though. It seems like it would be good to skip the unreachable calendar (don't delete the events) either for a certain amount of time or certain number of retries/runs of the code, but then after that threshold is reached, send an email to let the user know that calendar is unresponsive. Sounds like the best of both worlds. In some separate code I'm working on, I've used this "PropertiesService.getUserProperties().setProperty(xyz);" to store information that persists across runs (I think of it like a cookie). This PropertiesService could hold the number of consecutive failures to be used in the threshold.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare with this approach: #403

continue;
}
Logger.log("Syncing " + responses.length + " calendars to " + targetCalendarName);

//------------------------ Get target calendar information------------------------
Expand Down