Kimi K3.1 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 Haiku 5.5.

Gold bugs found
8 of 9
Comments published
14
Comments matching a bug
8
Comments not matching
6
Cost of this PR
$3.545

Published comments (14)

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

Collective bookings drop team calendars when no default calendar exists — For collective events, a null `evt.destinationCalendar` makes the optional push discard every team destination, leaving hosts without calendar events. Initialize it to an empty array before pushing `teamDestinationCalendars`.

mediumbugpackages/core/EventManager.ts:375-380

Legacy destination events omit the external calendar ID — Legacy destinations lose the external calendar needed for later updates and deletes because `EventManager.create` reads only `result.externalId`. Pass `destination.externalId` as the third argument to `createEvent`, matching the credential-specific branch.

mediumbugpackages/core/EventManager.ts:205-209

Calendar references lose `externalId` and `credentialId` after location edits — After a location edit, `CalendarManager.updateEvent` results lack `externalId` and `credentialId`, so every updated calendar reference is persisted without both fields. Return those fields from `updateEvent` or copy them from the booking reference being updated.

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

Hangout patch uses an undefined calendarId after the primary-calendar fallback — When insertion falls back to `primary`, the Hangout patch still uses bare `selectedCalendar`, sending an undefined `calendarId`. Apply the same `selectedCalendar || "primary"` fallback to the patch.

mediumbugpackages/core/EventManager.ts:502-504

Rescheduling a collective booking leaves stale host calendar events — The `newBookingId` branch still uses `.find` and deletes only the first old event, leaving stale events on other hosts' calendars after a collective reschedule. Iterate over every old calendar reference and delete each with its own credential and external calendar ID.

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

Recurring cancellations duplicate deletions and skip additional hosts — The recurring branch repeats deletions across organizer credentials while selecting only each booking's first reference, so additional hosts' events can remain. Scope deletion to `calendarCredential` and the updated-booking reference matching the outer `reference`.

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

Credential-less destinations incorrectly create events in primary — A destination without `credentialId` cannot match the numeric lookup, so `createAllCalendarEvents` inserts into `"primary"` instead of the selected calendar. Preserve that path by falling back to the `externalId` of the destination whose `credentialId` is null or undefined.

mediumsecuritypackages/features/bookings/lib/handleNewBooking.ts:757-760

Prisma errors expose internal database details to clients — `PrismaClientKnownRequestError.message` can expose queries, schema details, and database diagnostics to clients when user loading fails. Log the detailed error server-side and return a generic `HttpError` message, propagating only messages explicitly safe for clients.

mediumbugpackages/core/EventManager.ts:118-119

Missing destination calendar throws before Cal Video fallback — Use `mainHostDestinationCalendar?.integration !== "google_calendar"`.

mediumbugpackages/core/CalendarManager.ts:234-236

Event creation drops the destination calendar for secondary hosts — Secondary-host calls can combine the organizer's calendar ID with the secondary host's credentials because the new `externalId` argument never reaches adapters that select `destinationCalendar[0]`, causing failed or missing events. Pass the current destination through the adapter contract or make each adapter select the destination matching `credential.id`. **Also found in:** - `packages/app-store/office365calendar/lib/CalendarService.ts:72-76`

mediumbugpackages/core/EventManager.ts:169-170

Non-calendar references lose their credential ID — Non-calendar and video references now persist `credentialId: undefined`, losing the credential needed for later credential-specific operations. Preserve `result.credentialId` in the non-calendar branch while keeping calendar-specific `externalCalendarId` handling.

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

Update and delete fallbacks look up a destination by a falsy ID — When `externalCalendarId` is falsy, searching for a destination with that same value finds no normal calendar, so update and delete pass an undefined `calendarId`. Use the appropriate destination calendar's `externalId` here and in the delete path. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317` - `packages/app-store/googlecalendar/lib/CalendarService.ts:314-320` - `packages/app-store/googlecalendar/lib/CalendarService.ts:314-317`

mediumbugpackages/features/ee/payments/api/webhook.ts:207-210

Paid collective bookings only create the organizer's calendar event — A one-element destination array before `EventManager.create` leaves only the organizer with a calendar event after payment for a collective booking. Load all collective hosts' destination calendars in both payment-success paths before creating events and references. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/confirm.handler.ts:175-179`

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

Organizations created without team billing cannot be published — With team billing disabled, omitting both `slug` and `requestedSlug` leaves new organizations unable to pass the publish check in `publish.handler.ts`. Restore the negated condition for `slug` and keep `requestedSlug` when billing is enabled.

Gold bugs found (8)

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.

Gold bugs missed (1)

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.