From 62f57bb03517401b46f90eb8da9afc91e06499b8 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Oct 2025 07:42:05 +0000 Subject: [PATCH] Fix ensure_google_calendar to fetch all calendars with pagination to avoid missing calendars on later pages --- .../advoware_cal_sync/calendar_sync_event_step.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py index db985ac8..aae071cb 100644 --- a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py +++ b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py @@ -167,9 +167,20 @@ async def ensure_google_calendar(service, employee_kuerzel, context=None): try: # Enforce rate limiting for calendar list fetch await enforce_global_rate_limit(context) - calendar_list = service.calendarList().list().execute() + + # Fetch all calendars with pagination + all_calendars = [] + page_token = None + while True: + calendar_list = service.calendarList().list(pageToken=page_token, maxResults=250).execute() + calendars = calendar_list.get('items', []) + all_calendars.extend(calendars) + page_token = calendar_list.get('nextPageToken') + if not page_token: + break + calendar_id = None - for calendar in calendar_list.get('items', []): + for calendar in all_calendars: if calendar['summary'] == calendar_name: calendar_id = calendar['id'] break