DeepSeek V4.1 Flash · Balanced

fix-handle-collective-multiple-host-on-destinationcalendar-cal-com

cal.com · TypeScript · S · 30–99 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
5 of 9
Comments published
7
Comments matching a bug
5
Comments not matching
2
Cost of this PR
$0.173

Published comments (7)

highbugpackages/core/EventManager.ts:118-119

Dereference of possibly-undefined mainHostDestinationCalendar throws — `mainHostDestinationCalendar` is `undefined` when `evt.destinationCalendar` is null or empty, so every Google Meet booking without a destination calendar throws a TypeError and aborts event creation. Add optional chaining before `.integration`, matching the previous `evt.destinationCalendar?.integration`.

highbugpackages/core/EventManager.ts:169-170

Calendar references lose externalCalendarId for non-credential destinations — `createEvent` only sets `result.externalId` when passed a third argument, which only the `destination.credentialId` branch does, so references from the type-based and no-destination branches lose `externalCalendarId` and cannot be matched later. Fall back to the matching entry in `evt.destinationCalendar` for `result.externalId`.

highbugpackages/core/EventManager.ts:169-171

Video credentialId is dropped when creating booking references — `createMeeting` returns a video `credentialId`, but this branch hardcodes `undefined`, and cancellation only calls `deleteMeeting` when `bookingVideoReference.credentialId` is set, so Zoom/Webex/Daily meetings are never deleted. Use `result.credentialId` in the non-calendar branch too.

highbugpackages/features/bookings/lib/handleNewBooking.ts:1077-1079

Collective team destination calendars dropped when organizer has none — `evt.destinationCalendar?.push(...teamDestinationCalendars)` is a no-op when both the organizer and event type have no destination calendar, discarding the co-hosts' calendars, which is the bug this PR targets. Build `evt.destinationCalendar` as `[...(evt.destinationCalendar ?? []), ...teamDestinationCalendars]` instead of optional-chained `push`.

highbugpackages/app-store/googlecalendar/lib/CalendarService.ts:254-256

Fallback never matches, passing undefined calendarId to events.update — The fallback only runs when `externalCalendarId` is falsy, so its predicate can never match and `calendarId` reaches `calendar.events.update` as `undefined`, failing updates for references lacking `externalCalendarId`. Use `mainHostDestinationCalendar?.externalId` as the fallback, as before. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317`

mediumbugpackages/core/EventManager.ts:208-209

updateLocation drops calendar credential and external IDs from references — `CalendarManager.updateEvent` returns no `externalId` or `credentialId`, so `updateLocation` persists references with both fields `undefined` and later updates and cancellations cannot resolve the right calendar. Fall back to the matching entry in `booking.references` when `result` lacks them, as the previous code took these from `evt.destinationCalendar`.

mediumperformancepackages/features/bookings/lib/handleCancelBooking.ts:449-461

Recurring calendar deletion sweep repeats for each booking reference — The sweep is nested in the new `bookingCalendarReference` loop but does not depend on `reference`, so a booking with N references issues N× the identical `calendar.deleteEvent` calls and duplicates in `apiDeletes`. Run the sweep only once, not per reference.

Gold bugs found (5)

highWhen externalCalendarId is absent, updateEvent/deleteEvent look for a destination calendar whose externalId equals that absent value, so the lookup never matches and the configured destination calendar is no longer used.
highThe Google Meet fallback reads mainHostDestinationCalendar.integration without optional chaining, so a Meet booking with a null or empty destinationCalendar throws instead of falling back to Cal Video.
highFor collective events whose organizer has no destination calendar, destinationCalendar is null and the optional push drops all other hosts' destination calendars, so those hosts never get calendar events.
highVideo booking references are now saved without their credentialId, so cancelling the booking can no longer find the video credential and the meeting is not deleted.
mediumWhen cancelling a recurring booking with multiple calendar references, the recurring-event deletion over all remaining bookings and credentials runs once per reference, causing duplicate delete calls and errors.

Gold bugs missed (4)

highThe organization slug is now set only when team billing is enabled (inverted condition), so with billing both slug and requestedSlug are set and without billing neither is.
highOffice365 (and Lark) createEvent ignore the new credentialId argument and always use the first destination calendar, so in collective bookings other hosts' credentials target the organizer's calendar instead of their own.
highCancelling all remaining occurrences of a recurring collective booking deletes only the first calendar reference of each booking, repeated once per host, so the other hosts' events stay on their calendars.
mediumIn Google createEvent, when no destination calendar matches the credentialId, the hangout-link events.patch is called with an undefined calendarId and fails, so the Meet link is not added to the event description.