GLM-5.3 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 Opus 5.5.

Gold bugs found
6 of 20
Comments published
6
Comments matching a bug
6
Comments not matching
0
Cost of this PR
$0.117

Published comments (6)

highbugpackages/core/EventManager.ts:117-121

Missing optional chaining on mainHostDestinationCalendar crashes when no destination calendar — When `evt.destinationCalendar` is null or empty, `mainHostDestinationCalendar.integration` throws a `TypeError`, crashing `EventManager.create` for Meet bookings without a calendar — exactly the case the fallback covers. Restore the optional chaining via `mainHostDestinationCalendar?.integration`.

highbugpackages/core/EventManager.ts:493-542

Stale `credential` leaks across loop iterations in updateAllCalendarEvents — If a reference's `credentialId` is found neither in `this.calendarCredentials` nor in the DB, `updateEvent` receives the previous iteration's `credential` and silently updates the wrong host's calendar event. Reset `credential = undefined` at the top of each iteration, or scope it there.

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

Inverted IS_TEAM_BILLING_ENABLED check creates org without slug on self-hosted — On self-hosted instances organizations are now created without a `slug`, breaking their URLs, while hosted instances get it at creation and skip the publish/checkout flow that should set it afterwards. Negate the flag: `...(!IS_TEAM_BILLING_ENABLED ? { slug } : {})`.

highbugpackages/core/EventManager.ts:169-170

credentialId dropped for video references in referencesToCreate — Video references are persisted with `credentialId: null`, so consumers that resolve the credential from the reference — `deleteMeeting` in handleNewBooking.ts and `updateMeeting` in handleCancelBooking.ts — skip silently, leaving Zoom and Meet meetings orphaned or unupdated. Keep `credentialId: result.credentialId ?? undefined` for all types and gate only `externalCalendarId` by `isCalendarType`.

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

Collective event drops team destination calendars when organizer has none — When the organizer and event type have no destination calendar, `evt.destinationCalendar` is null and the optional chain makes this push a silent no-op, so COLLECTIVE events get no calendar event and team hosts are never invited. Initialize it to an empty array, e.g. `(evt.destinationCalendar ??= []).push(...)`.

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

`updateEvent` fallback compares `externalCalendarId` against itself — When the booking reference lacks `externalCalendarId`, the fallback looks for that same falsy value in `event.destinationCalendar`, never matches, and reschedules fail with `calendarId: undefined` in `calendar.events.update`. Use the main host's calendar instead, `mainHostDestinationCalendar?.externalId`. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:314-320`

Gold bugs found (6)

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.
mediumClaims updateAllCalendarEvents passes an undefined credential to updateEvent when reference.credentialId points to a credential that cannot be found.
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.

Gold bugs missed (14)

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.
highGoogle createEvent picks the target calendar only by matching credentialId, so destination calendars without a credentialId are ignored and events are created on the primary calendar instead.
mediumFor destination calendars without a credentialId, createEvent is called without the externalId, so the booking reference is stored with an undefined externalCalendarId.
highFor collective bookings, CalDAV/Apple createEvent matches calendars only against the main host's destination externalId, so other hosts' calendars are filtered out and they silently get no calendar event.
highCalendarEvent.destinationCalendar became an array and evt is spread into webhook payloads, so payload.destinationCalendar changes from an object/null to an array and subscribers reading .externalId or .integration break.
highWhen rescheduling merges into a new booking, only the first old `_calendar` reference is deleted via `.find()`, leaving stale events on other hosts' calendars for collective bookings; iterate all old calendar references.
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.
mediumloadUsers forwards raw Prisma error messages to the client in a 400 response, exposing internal model and query details.
mediumcreateAllCalendarEvents awaits the credential lookup and createEvent for each destination calendar in sequence, so collective booking latency grows linearly with host count.
highThe Stripe and PayPal payment-success handlers build destinationCalendar as a one-element array (booking or organizer calendar) before EventManager.create, so paid collective bookings create the calendar event only for the organizer and not for the other hosts.
mediumGoogle createEvent selects the target calendar by credentialId only while the booking reference stores the destination's externalId; when two destination calendars share a credential the event is inserted into the first match but the reference records the other calendar, breaking later updates/deletes.
mediumIn createAllCalendarEvents the no-credentialId branch runs per destination and reuses the organizer's credentials filtered by integration, so several same-integration destinations without credentialId create duplicate events on the organizer's calendar.