GLM-5.3 · 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
7 of 9
Comments published
12
Comments matching a bug
7
Comments not matching
5
Cost of this PR
$1.668

Published comments (12)

highbugpackages/core/EventManager.ts:118-119

Dereference of possibly undefined mainHostDestinationCalendar crashes EventManager.create — Whenever `evt.destinationCalendar` is null or empty — as callers like `handleNewBooking.ts` produce — dereferencing `mainHostDestinationCalendar.integration` throws a TypeError that crashes the booking/payment flow instead of falling back to Cal Video. Use `mainHostDestinationCalendar?.integration`.

highbugpackages/core/EventManager.ts:208-209

References created by updateLocation lose externalCalendarId and credentialId — `CalendarManager.updateEvent` returns neither `externalId` nor `credentialId`, so every reference `updateLocation` creates stores undefined, and later reschedule/cancel operations can't resolve the right calendar. Return those fields or fall back to `evt.destinationCalendar` values.

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

Inverted IS_TEAM_BILLING_ENABLED condition drops slug or bypasses requestedSlug flow — The ternary is inverted: with billing disabled, self-hosted orgs get no slug even though `vercelCreateDomain(slug)` registered their subdomain, making them unreachable via `getSlugOrRequestedSlug`; with billing enabled it bypasses the `requestedSlug` approval flow. Restore the `!IS_TEAM_BILLING_ENABLED` condition.

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

createEvent posts to first destination calendar regardless of which host credential was invoked — Each host's credential is now invoked per destination, yet `createEvent` still posts to `destinationCalendar[0].externalId`, so a member's token 404s on another host's calendar id; `LarkCalendarService` makes the same mistake. Match the destination whose `credentialId` equals the invoked one, as `GoogleCalendarService` does.

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

destinationCalendar initialized to null drops member calendars for collective events — When no event-type or organizer destination exists, `evt.destinationCalendar` is null, so `evt.destinationCalendar?.push(...teamDestinationCalendars)` silently no-ops and `createAllCalendarEvents` falls back to organizer credentials only. Initialize the field to `[]` like the other handlers.

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

updateEvent fallback never matches, leaving calendarId undefined — The fallback `find((cal) => cal.externalId === externalCalendarId)` only runs when `externalCalendarId` is falsy, so it never matches and `calendar.events.update` receives `calendarId: undefined`, silently failing reschedules for bookings whose reference lacks that field. Use `event.destinationCalendar?.[0]?.externalId` instead. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317`

mediumbugpackages/core/EventManager.ts:169-170

Video meeting references lose credentialId, preventing meeting deletion on cancellation — `handleCancelBooking.ts` only calls `deleteMeeting` when `credentialId` is set, so canceled Zoom/Teams/Daily rooms are left orphaned. Use `result.credentialId` for the video branch — `createMeeting` in `videoClient.ts` returns it.

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

Destination calendar without credentialId never matched; event created on "primary" — `DestinationCalendar.credentialId` is nullable (see `schema.prisma`), so destinations without one never match and events are silently created on `"primary"`, breaking the follow-up `hangoutLink` patch. Fall back to the first destination calendar's `externalId` when no match is found.

mediumbugpackages/core/EventManager.ts:375-382

Duplicate events when destinations share integration without credentialId — For collective events with several destinations of the same credential-less integration, the no-credentialId branch in `createAllCalendarEvents` re-runs the same credentials per destination, creating duplicate events on one calendar. Deduplicate credentials across destinations, e.g. with a Set of used credential ids.

mediumperformancepackages/core/EventManager.ts:339-373

Sequential createEvent awaits make booking latency scale with host count — Resolve the per-destination creations with `Promise.all`, as the no-credentialId branch already does.

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

Recurring-event deletion sweep re-runs for every calendar reference, duplicating delete calls — The recurring-event sweep never reads `reference`, yet it re-runs per calendar reference, multiplying delete API calls and re-deleting already-removed events. Hoist this block out of the per-reference loop since its inputs don't depend on it.

mediumbugpackages/core/EventManager.ts:495-504

Reschedule merge path deletes only first old calendar reference, orphaning others — On reschedules with `newBookingId`, the merge path still deletes only the first old calendar reference via `booking.references.find(...)`, leaving other hosts' events orphaned with stale times. Iterate all old `_calendar` references for deletion, mirroring the per-reference loop added here.

Gold bugs found (7)

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

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.