Claude Sonnet 5.5 · Heavy

add-guest-management-functionality-to-existing-bookings-cal-com

cal.com · TypeScript · M · 100–299 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
5 of 8
Comments published
8
Comments matching a bug
5
Comments not matching
3
Cost of this PR
$1.765

Published comments (8)

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:158-165

`EventManager` uses the requesting user's credentials, not the organizer's — Calendar updates run against the wrong credentials, so `updateCalendarAttendees` does not update the organizer's event when an attendee or team admin adds guests. Build `EventManager` from `booking.user` and its credentials, as the other booking handlers do.

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46-48

`isTeamAdminOrOwner` joins `isTeamAdmin` and `isTeamOwner` with `&&` — `isTeamAdmin` already matches admins and owners, so joining it with `isTeamOwner` using `&&` limits access to owners and returns FORBIDDEN for other team admins. Use `isTeamAdmin` alone or join the checks with `||`, and skip the lookup when `teamId` is null.

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-78

Blacklisted guest emails bypass filter when entered with upper-case letters — The blacklist is lowercased but `guest` is compared as typed, so a blacklisted address with upper-case letters gets through. Compare `guest.toLowerCase()` against `blacklistedGuestEmails`.

mediumperformancepackages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:3-6

Unbounded guests array allows mass email sending in one request — One authenticated call can add arbitrarily many attendees, and `sendAddGuestsEmails` emails every attendee, the organizer and each team member, so work grows with guests × attendees. Add `.min(1)` and `.max(N)` to the `guests` array.

mediumbugapps/web/components/dialog/AddGuestsDialog.tsx:43-44

Error toast always shows raw error code prefix; fallback message is unreachable — The message is always a truthy string, so the `t("unable_to_add_guests")` fallback never runs and users see a raw prefix such as "FORBIDDEN:". Show the translated `err.message`, falling back to `t("unable_to_add_guests")` when it is empty.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-78

Duplicate guest emails in input are not deduplicated before createMany — Uniqueness is enforced only in the client dialog, so a direct API call with repeated emails makes `createMany` insert duplicate attendee rows. Dedupe `guests` before filtering, and compare against the lowercased `blacklistedGuestEmails`.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168

sendAddGuestsEmails receives unfiltered guests instead of uniqueGuests — Duplicate and blacklisted emails still match `newGuests.includes(attendee.email)`, so existing attendees get a full scheduled-invite email instead of the add-guests notice. Pass `uniqueGuests` to `sendAddGuestsEmails` instead of `guests`.

mediumsecuritypackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-78

Case-sensitive guest email checks allow duplicate or blacklisted guests — The `guest === attendee.email` check is case-sensitive, so a case variant of an existing attendee's email counts as a new guest and creates a duplicate. Compare lowercased values in the `uniqueGuests` filter, and dedupe submitted guests case-insensitively too.

Gold bugs found (5)

highisTeamAdminOrOwner combines isTeamAdmin and isTeamOwner with &&, so only team owners pass; team admins who are not organizer or attendee are wrongly rejected with FORBIDDEN.
highThe guest blacklist is lowercased but incoming guest emails are compared without normalization, so a blacklisted address submitted with different casing bypasses BLACKLISTED_GUEST_EMAILS and is added and emailed.
mediumThe server never deduplicates the guests array, so a request with the same email twice inserts duplicate attendee rows for the booking.
mediumThe handler passes the unfiltered guests list to sendAddGuestsEmails, which uses it to pick who gets AttendeeScheduledEmail, so existing attendees included in the request receive a new-booking confirmation instead of the add-guests email.
highEventManager is created with the requesting user's credentials, so when a non-organizer adds guests the organizer's calendar event is not updated (or the wrong account is used) for references without a credentialId.

Gold bugs missed (3)

mediumsendAddGuestsEmails ignores the event type's disableStandardEmails settings, so hosts and attendees receive add-guests emails even when standard emails are disabled.
mediumThe add-guests handler omits booking.iCalUID from the CalendarEvent, so the add-guests emails' .ics attachments use booking.uid as UID and recipients' calendars treat them as a new event rather than an update of the original booking invite.
highGuest email uniqueness is checked case-sensitively, so case variants of the same address are accepted as distinct guests (and slip past the lowercased blacklist).