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)
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`.
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.
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.
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.
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.
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`.
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.
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.
Missing destination calendar throws before Cal Video fallback — Use `mainHostDestinationCalendar?.integration !== "google_calendar"`.
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`
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.
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`
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`
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.