GPT-6.1 Sol · 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
6 of 8
Comments published
7
Comments matching a bug
6
Comments not matching
1
Cost of this PR
$1.952

Published comments (7)

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

Team administrators are incorrectly forbidden from adding guests — An `ADMIN` who is neither the organizer nor an attendee receives `FORBIDDEN` because `isTeamAdminOrOwner` requires both checks to pass. Use `isTeamAdmin` alone, which accepts both `ADMIN` and `OWNER`, or combine it with `isTeamOwner` using OR.

highsecuritypackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-77

Guest email blacklist can be bypassed with capitalization or aliases — Comparing unchanged guest input against lowercased `blacklistedGuestEmails` lets callers invite blocked addresses by changing capitalization. Normalize submitted addresses before comparison and apply the base-email normalization used by `handleNewBooking`.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:136-138

Guest invitations lose the stored iCalendar identity and update sequence — Without `booking.iCalUID` and `booking.iCalSequence`, `generateIcsString` can produce a separate event or an update recipients ignore as stale. Preserve `booking.iCalUID` and persist an incremented `booking.iCalSequence` for the invitation.

mediumbugpackages/emails/email-manager.ts:525-529

Added-guest notifications ignore event-type email-disable settings — `sendAddGuestsEmails` sends notifications despite event-type email-disable settings. Pass event-type metadata from the handler and apply the host and attendee email-disable predicates used by `sendScheduledEmails` and `sendLocationChangeEmails` before queuing notifications.

mediumperformancepackages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:5

Unbounded guest arrays cause excessive database and email attachment work — Each address in `guests` adds a database attendee and an email whose ICS includes the attendee list, allowing unbounded fanout and quadratic attachment work per request. Add a server-side size limit to `guests` before insertion and notification generation.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:99-103

Guest insertion permits duplicate attendee emails, including concurrent requests — `uniqueGuests` checks only existing attendees, so repeated input addresses or concurrent requests can make `createMany` insert duplicates and trigger duplicate notifications. Deduplicate submitted emails and enforce atomic per-booking email uniqueness at the write boundary. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-78`

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

Existing attendees receive fresh booking confirmations when guests are added — When a request mixes existing and new attendees, passing `guests` makes `sendAddGuestsEmails` send `AttendeeScheduledEmail` to existing attendees instead of a guests-added notification. Pass `uniqueGuests` as the second argument so only newly added attendees receive booking confirmations.

Gold bugs found (6)

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

Gold bugs missed (2)

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