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)
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`.
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`.
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.
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`.
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`
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`.
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.