Claude Sonnet 5.5 · Balanced

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

cal.com · TypeScript · M · 100–299 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
5 of 8
Comments published
7
Comments matching a bug
5
Comments not matching
2
Cost of this PR
$0.647

Published comments (7)

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

Team admin check uses && so admins who are not owners are denied — Legitimate team admins who are not owners cannot add guests to team bookings they do not host. Combine the `isTeamAdmin` and `isTeamOwner` checks with `||` instead of `&&`.

highsecuritypackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:70-78

Case-sensitive guest email check bypasses blacklist and duplicate attendee check — A mixed-case address like `Blocked@Example.com` slips past `BLACKLISTED_GUEST_EMAILS` and the duplicate attendee check. Compare `guest.toLowerCase()` against the blacklist and the attendee emails.

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

Calendar update uses caller's credentials instead of the organizer's — `EventManager` is built from `getUsersCredentials(ctx.user)`, so when an attendee or team admin adds guests, the organizer's calendar event fails to update or errors. Build the credentials and `EventManager` from `booking.user`, and catch calendar failures.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:167-169

sendAddGuestsEmails called with unfiltered guests instead of uniqueGuests — A re-submitted existing attendee is treated as new and gets the 'scheduled' email instead of the 'guests added' one. Pass `uniqueGuests` to `sendAddGuestsEmails` instead of `guests`.

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

Guests array has no maximum length, enabling email spam and load — Without a limit, any user with booking access can submit a huge `guests` list, creating many attendee rows and flooding recipients with emails. Add `.min(1).max(N)` to the `guests` array with a reasonable N.

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

Calendar update failure aborts handler after guests are saved, skipping emails — If a calendar integration throws in `eventManager.updateCalendarAttendees`, the mutation errors and skips emails even though guests are saved, and a retry hits `emails_must_be_unique_valid`. Wrap the call in try/catch and log the error.

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

Duplicate guest emails in input are not deduplicated on the server — Duplicates within `guests` pass through `uniqueGuests`, so a direct tRPC call can create duplicate attendee rows and emails. Dedupe the input on the server with a lowercased `Set` and compare against existing attendees case-insensitively.

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