Claude Sonnet 5.5 · 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
7 of 9
Comments published
10
Comments matching a bug
7
Comments not matching
3
Cost of this PR
$2.805

Published comments (10)

highbugpackages/core/EventManager.ts:511-542

Undefined credential passed to updateEvent aborts remaining calendar updates — An undefined `credential` reaches `updateEvent` and throws a TypeError, aborting updates for all remaining calendar references. Skip the reference or push a failure result when `credential` is not found.

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

Team destination calendars dropped when no event type or organizer calendar exists — Initialize it as `[]` instead of `null`.

highbugpackages/core/EventManager.ts:375-382

createEvent omits destination.externalId when destination has no credentialId — Without `destination.externalId`, the saved reference has an undefined `externalCalendarId`, so reschedule and cancel lose the target calendar and Google falls back to "primary". Pass `destination.externalId` as the third argument to `createEvent`, and have the calendar services select by `externalId` when no `credentialId` matches.

highbugpackages/core/EventManager.ts:118-119

TypeError on Google Meet booking when destinationCalendar is empty — Use `mainHostDestinationCalendar?.integration` so it falls back to Cal Video.

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

Calendar ID fallback in updateEvent can never match and yields undefined — The fallback `find` only runs when `externalCalendarId` is falsy, so it never matches and `selectedCalendar` is undefined, sending `events.update` and `events.patch` without a `calendarId`. Fall back to `mainHostDestinationCalendar?.externalId` or "primary" instead. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:315-317`

highbugpackages/core/EventManager.ts:169-170

Video booking references lose credentialId for non-calendar results — Video booking references no longer store their credential, so later reschedule and cancel flows that look it up by `credentialId` must guess. Keep `credentialId: result.credentialId` for non-calendar types.

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

events.patch uses undefined calendarId when no destination calendar matches — The later `events.patch` call still passes the raw `selectedCalendar`, which is often undefined now that `events.insert` falls back to "primary", so the Meet link patch fails or hits the wrong calendar. Compute `selectedCalendar` once with the "primary" fallback and use it in both calls.

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

Recurring calendar deletion runs once per reference inside loop — With N calendar references, the remaining bookings' events are deleted N times per credential, causing duplicate API calls and spurious errors. Move the recurring deletion outside the loop and keep only the non-recurring path per reference.

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

Raw Prisma error message leaked to client in loadUsers catch block — Prisma messages expose query and schema details, and `loadUsers` returns them to the booking client in a 400. Log the original error server-side and throw a generic "Unable to load users" instead.

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

Slug is set only when team billing is enabled, inverting original condition — The inverted condition sets `slug` only when `IS_TEAM_BILLING_ENABLED`, the opposite of the original behavior. Restore the negation with `!IS_TEAM_BILLING_ENABLED`.

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.
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.
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.

Gold bugs missed (2)

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.