Amazon Ergo 1.0 · 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
- 11 of 20
- Comments published
- 12
- Comments matching a bug
- 11
- Comments not matching
- 1
- Cost of this PR
- $4.833
Published comments (12)
Recurring cancellation ignores `reference` and uses organizer credentials — Recurring collective cancellations leave other hosts' calendar events behind. Delete through each current `reference`, using its `credentialId`, `uid`, and `externalCalendarId` and the DB-fetched credential when needed, rather than scanning only `bookingToDelete.user.credentials`.
Video booking references lose the credential that owns the meeting — Without `credentialId`, cancellation and rescheduling can fail to select the credential that owns the meeting, especially for collective hosts. Persist `result.credentialId` on video references so `bookingVideoReference.credentialId` retains the ID returned by `createVideoEvent`.
`credential` leaks across `calendarReference` iterations — A missing credential can reuse the previous iteration's value, updating or deleting the wrong calendar event, or call `updateEvent` with `undefined` on the first pass. Reset `credential` inside the loop and skip or fail that reference when neither `this.calendarCredentials` nor the Prisma lookup provides one with `app.slug`.
Collective host destination calendars are dropped when defaults are null — With both default calendars null, the optional push silently drops collective hosts' destination calendars, leaving only the organizer's credentials in `createAllCalendarEvents`. Initialize `evt.destinationCalendar` from `evt.destinationCalendar ?? []` before appending `teamDestinationCalendars`.
Prisma error details are exposed to booking API callers — Copying `error.message` from a `Prisma.PrismaClientKnownRequestError` can expose query, schema, and database internals to booking API callers. Log the original error server-side and return `Unable to load users`, while rethrowing existing `HttpError` instances unchanged.
Google Meet fallback throws when no destination calendar exists — When `evt.destinationCalendar` is null or empty, dereferencing `mainHostDestinationCalendar.integration` throws instead of falling back to Cal Video. Use optional chaining on `mainHostDestinationCalendar?.integration` so the Google Meet condition remains true.
Delete fallback never resolves the destination calendar — Without an `externalCalendarId`, comparing it with `cal.externalId` cannot resolve the destination calendar, leaving `calendarId` undefined and failing the delete; `updateEvent` repeats the bug. Use `event.destinationCalendar?.[0]?.externalId` in both fallbacks. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:254-256`
Destination calendars without `credentialId` silently use `primary` — Destination calendars stored without `credentialId` never match, so the `selectedCalendar` fallback inserts the event into `primary` instead of the configured calendar. Fall back to the first destination calendar's `externalId`, preserving the legacy shape handled by `EventManager.createAllCalendarEvents`.
createEvent now selects the target calendar only via `cal.credentialId === credentialId` — For destination calendars with null `credentialId`, `EventManager.createAllCalendarEvents` calls `createEvent` for every integration credential, but none can match, so events land in `primary`. Fall back to `mainHostDestinationCalendar?.externalId` when `cal.credentialId === credentialId` finds nothing.
This fallback branch calls `createEvent(c, event)` without `destination.externalId` — For destination calendars without `credentialId`, the resulting booking reference persists a null `externalCalendarId`, so later updates and deletes cannot find the calendar. Pass `destination.externalId` through this `createEvent(c, event)` fallback so it is returned and stored on the reference.
Slug condition polarity is inverted — With billing enabled, both `slug` and `requestedSlug` are written; with it disabled, neither slug is written, breaking organization creation in both modes. Restore `!IS_TEAM_BILLING_ENABLED` so `slug` is included only when team billing is disabled.
createEvent uses the first destination calendar for every credential — A collective host whose Lark destination is not first can have its event created with another host's calendar ID, causing an API failure or wrong-calendar placement. Select the `event.destinationCalendar` entry whose `credentialId` matches the active credential instead of always using `event.destinationCalendar[0]`. **Also found in:** - `packages/lib/CalendarService.ts:156-164`