DeepSeek V4 Pro · 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 Opus 5.5.

Gold bugs found
6 of 20
Comments published
9
Comments matching a bug
6
Comments not matching
3
Cost of this PR
$1.679

Published comments (9)

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

Collective team calendars silently dropped when destinationCalendar is null — When both destination calendars are null, the optional chaining silently drops all team destination calendars, so collective hosts with connected calendars never get invited. Initialize the array instead of relying on `?.push`.

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

Duplicate deletes for recurring cancellation across calendar references — Each extra calendar reference re-runs the full credential and booking loop, issuing duplicate delete calls for collective cancellations. Move this block outside the reference loop and execute it once.

mediumbugpackages/features/bookings/lib/handleNewBooking.ts:761

Use localization key for hard-coded loadUsers 500 error message — Users will see this error in English regardless of their locale, unlike neighboring `HttpError` messages that use translation keys. Replace the literal with a localization key such as `unable_to_load_users`.

mediumsecuritypackages/core/EventManager.ts:515-542

Calendar credential key leaked to updateEvent error log — The fallback credential includes the raw `key` secret, and `updateEvent` logs the whole `credential` object when `bookingRefUid` is empty. Redact or omit `key` before passing it to the update path.

mediumbugpackages/core/EventManager.ts:118-119

Unsafe access of destinationCalendar integration when no calendar exists — When no destination calendar exists the array is empty, so destructuring yields `undefined` and dereferencing `.integration` throws a `TypeError` instead of falling back to Cal Video. Use `mainHostDestinationCalendar?.integration !== "google_calendar"`.

mediumbugpackages/core/EventManager.ts:169-170

Non-calendar branch drops video credentialId — Cancellation fails because the video reference is stored without a `credentialId`, but `handleCancelBooking.ts:491` only deletes when that field is truthy. Keep `result.credentialId` for non-calendar result types.

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

External calendar ID fallback compares cal.externalId to undefined — In the falsy branch the comparison always evaluates `undefined === undefined`, so `selectedCalendar` becomes undefined and `events.update` is called with a missing `calendarId`. Fall back to `event.destinationCalendar?.[0]?.externalId` instead. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317`

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

Org creation slug condition inverted — This flips the self-hosted behavior: billing-disabled orgs get a null `slug`, while billing-enabled orgs bypass the `requestedSlug` publishing flow. Restore the `!IS_TEAM_BILLING_ENABLED` condition for `slug`.

mediumbugpackages/core/EventManager.ts:208-209

updateLocation drops destinationCalendar fallback for externalId/credentialId — `CalendarManager.updateEvent` never returns `externalId` or `credentialId`, so update flows now store undefined values and lose the previous destination-calendar fallback. Retain fallbacks to `evt.destinationCalendar?.[0]` for these fields.

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