Skip to content

Skip cancelled Google Calendar events before sync matching#523

Closed
Zhepyrx wants to merge 1 commit into
derekantrican:masterfrom
Zhepyrx:fix-skip-cancelled-calendar-events
Closed

Skip cancelled Google Calendar events before sync matching#523
Zhepyrx wants to merge 1 commit into
derekantrican:masterfrom
Zhepyrx:fix-skip-cancelled-calendar-events

Conversation

@Zhepyrx

@Zhepyrx Zhepyrx commented May 12, 2026

Copy link
Copy Markdown

Fixes #315

Summary

  • Filter existing Google Calendar events with status: "cancelled" before building the calendarEventsIds matching array.
  • Keep confirmed/tentative/statusless events eligible for normal update matching.
  • Log how many cancelled existing events were skipped when any are present.

Why

The sync fetches existing Google Calendar events with showDeleted: false, but issue discussion reports that cancelled events can still appear in this result set. If a cancelled event has the same extended private ID as an incoming ICS event, the sync attempts Calendar.Events.update(...) against the cancelled event and can fail with Invalid start time.

Filtering cancelled existing events before the ID/MD5 arrays are built prevents them from becoming update candidates.

Verification

node --check --input-type=commonjs < Code.gs
node --check --input-type=commonjs < Helpers.gs
git diff --check HEAD~1 HEAD
node -e 'const events=[{id:"1",status:"confirmed"},{id:"2",status:"cancelled"},{id:"3"},null,undefined,{id:"4",status:"CANCELLED"}]; const filtered=events.filter(function(event){return event != null && (event.status == null || event.status.toString().toLowerCase() != "cancelled");}); console.log(JSON.stringify(filtered.map(e => e.id))); if (JSON.stringify(filtered.map(e => e.id)) !== JSON.stringify(["1","3"])) process.exit(1);'

All commands passed locally.

@Zhepyrx

Zhepyrx commented May 12, 2026

Copy link
Copy Markdown
Author

Closing this because I found #520 after opening, and it addresses the same IssueHunt-funded issue first. My PR added a slightly more defensive filter/log, but keeping a duplicate open would add maintainer noise.

@Zhepyrx Zhepyrx closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Invalid start time' error from calendar.events.update

1 participant