Kimi K3.1 Pro · 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
9 of 9
Comments published
12
Comments matching a bug
9
Comments not matching
3
Cost of this PR
$2.099

Published comments (12)

mediumbugpackages/core/EventManager.ts:118-120

Missing destination calendar crashes the Google Meet fallback — When `destinationCalendar` is null or empty and Google Meet is selected, `mainHostDestinationCalendar` is undefined and reading `.integration` throws before the intended Cal Video fallback. Use `mainHostDestinationCalendar?.integration` in the comparison.

mediumbugpackages/core/EventManager.ts:169-170

Non-calendar references discard the video credential ID — Preserve `result.credentialId` when `isCalendarType` is false.

mediumbugpackages/core/EventManager.ts:208-209

`CalendarManager.updateEvent` returns neither `externalId` nor `credentialId`, but… — Preserve the existing booking reference values or return these fields from `updateEvent`.

mediumbugpackages/core/EventManager.ts:375-381

createEvent omits destination.externalId for credential-less destinations — For a destination without `credentialId`, `createEvent` is called without `destination.externalId`; because reference creation now relies on `result.externalId`, these booking references lose `externalCalendarId` and later updates/deletes cannot reliably target the original calendar. Pass `destination.externalId` in this branch as well.

mediumbugpackages/features/bookings/lib/handleNewBooking.ts:1077-1078

Team destination calendars are dropped when no main destination exists — If neither the event type nor organizer has a destination calendar, `evt.destinationCalendar` remains null and the optional `push` silently discards every collected team destination, so other collective hosts get no calendar event. Initialize the array from `teamDestinationCalendars` when no main destination exists.

mediumbugpackages/trpc/server/routers/viewer/organizations/create.handler.ts:148-153

Inverted billing check assigns organization slugs to the wrong flow — The slug condition was inverted: billing-enabled organizations now receive a public slug before publishing, while billing-disabled organizations receive neither `slug` nor `requestedSlug`, breaking the expected organization setup/publish states. Restore `!IS_TEAM_BILLING_ENABLED` for `slug` and retain `requestedSlug` for the billing-enabled flow.

mediumbugpackages/app-store/googlecalendar/lib/CalendarService.ts:147-154

Hangout description patch can use an undefined calendar ID — `selectedCalendar` can be undefined when no destination matches the credential, and although insert falls back to `primary`, the subsequent Hangout-description patch at line 168 still passes the raw undefined value. Reuse the same `selectedCalendar || "primary"` fallback for the patch request.

mediumbugpackages/features/bookings/lib/handleCancelBooking.ts:423-461

Recurring cancellation repeats the full calendar deletion set per reference — The recurring-cancellation branch runs once for every calendar reference, yet each run already iterates all user calendar credentials and all updated bookings, so N references repeat the same remote deletion set N times. Move the all-bookings recurring deletion outside the reference loop or restrict each iteration to its own reference.

mediumperformancepackages/core/EventManager.ts:339-370

Every secondary collective-host destination missing from the organizer's credentials triggers its… — Bulk-load the required credentials and parallelize the independent event creations.

mediumbugpackages/features/bookings/lib/handleCancelBooking.ts:449-457

For recurring collective bookings, this inner loop always selects the first calendar reference… — Resolve each updated booking's matching reference and credential, including DB-fetched secondary-host credentials, instead of combining every organizer credential with `find`'s first reference.

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

Falsy externalCalendarId leaves updateEvent without a calendar ID — When `externalCalendarId` is null or empty, the fallback searches for a destination whose required string `externalId` equals that falsy value, so it always yields undefined and updates legacy references without a calendar ID. Fall back to `mainHostDestinationCalendar?.externalId` instead. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317`

mediumbugpackages/app-store/office365calendar/lib/CalendarService.ts:72-77

Office 365 event creation always uses the first host's calendar — EventManager now calls `createEvent` for every collective host credential, but this adapter always posts to the first destination's external ID; secondary hosts therefore authenticate with their own token against the organizer's calendar and event creation fails. Accept the supplied credential ID and select the matching destination for each invocation. **Also found in:** - `packages/app-store/larkcalendar/lib/CalendarService.ts:125-129` - `packages/lib/CalendarService.ts:156-165`

Gold bugs found (9)

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 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.
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.
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.
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 (0)

None.