MiniMax M3 · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
5 of 9
Comments published
8
Comments matching a bug
5
Comments not matching
3
Cost of this PR
$0.465

Published comments (8)

highbugpackages/core/EventManager.ts:117-119

EventManager throws when destination calendar array is empty/null — Any Google Meet booking with an empty or null `evt.destinationCalendar` throws on `mainHostDestinationCalendar.integration` because the optional chaining was lost during the array refactor in `EventManager.ts`. Add optional chaining to `mainHostDestinationCalendar?.integration` so the `TypeError` is avoided.

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

updateEvent selectedCalendar fallback predicate is self-referential — The `find` predicate in `updateEvent`'s fallback searches for the falsy `externalCalendarId` the ternary just rejected, so `selectedCalendar` becomes undefined and Google rejects the `update` call. Replace it with `event.destinationCalendar?.[0]?.externalId` so the fallback picks a real calendar.

highbugpackages/app-store/googlecalendar/lib/CalendarService.ts:315-317

deleteEvent fallback searches for the falsy externalCalendarId and loses destination calendar — The `find` predicate in `deleteEvent`'s fallback searches for the falsy `externalCalendarId` the ternary just rejected, then the `calendarId ? calendarId : defaultCalendarId` masking silently routes deletion to `primary`. Use `event.destinationCalendar?.[0]?.externalId` so the original destination calendar is honored.

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

Collective booking silently skips team destination calendars when organizer has none — When both `eventType.destinationCalendar` and `organizerUser.destinationCalendar` are null, `handleNewBooking.ts` initializes `evt.destinationCalendar` to `null`, and the optional-chained `push` drops every team host calendar silently. Initialize `evt.destinationCalendar` to `[]` so collective bookings actually populate host calendars.

highbugpackages/app-store/larkcalendar/lib/CalendarService.ts:125

Lark createEvent signature missing credentialId parameter — Add the `credentialId` parameter and pick the matching `DestinationCalendar` like `GoogleCalendarService` does.

highbugpackages/app-store/office365calendar/lib/CalendarService.ts:72-73

createEvent signature is missing the second credentialId parameter — The `Calendar` interface in `packages/types/Calendar.d.ts` and `CalendarManager` require `createEvent` to accept a `credentialId`, but Office365's `createEvent` in `Office365CalendarService.ts` still takes only `event`. Add the `credentialId` parameter and filter `event.destinationCalendar` by it like `GoogleCalendarService` does.

highbugpackages/trpc/server/routers/viewer/organizations/create.handler.ts:148-155

Organization slug is dropped when team billing is disabled — The slug condition in `create.handler.ts` is inverted: `IS_TEAM_BILLING_ENABLED ? { slug } : {}` drops the slug when team billing is off, making new organizations unsluggable. Restore the negation `!IS_TEAM_BILLING_ENABLED && { slug }` unless this reversal was intentional.

mediumperformancepackages/core/EventManager.ts:336-385

createAllCalendarEvents fetches missing credentials serially — `createAllCalendarEvents` awaits `prisma.credential.findUnique` sequentially per destination in `EventManager.ts`, so N missing host credentials issue N serial DB round-trips before any createEvent work begins. Collect missing ids and fetch with one `findMany` run before dispatching creates in parallel. **Also found in:** - `packages/core/EventManager.ts:493-554` - `packages/features/bookings/lib/handleCancelBooking.ts:416-484`

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

Gold bugs missed (4)

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.