Kimi K3.1 Pro · 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
16
Comments matching a bug
6
Comments not matching
10
Cost of this PR
$2.877

Published comments (16)

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:92-105

Guest insertion bypasses seat capacity and bookingSeat requirements — This unconditional attendee insertion also applies when `eventType.seatsPerTimeSlot` is set, bypassing the seat-capacity check and creating attendees without the required `bookingSeat` relation even though seated events disable guests. Reject seated bookings here or delegate to the seated-booking flow that checks capacity and creates the seat reference.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:44-56

Add Guests remains available for cancelled, rejected, and past bookings — After authorization, the handler never rejects CANCELLED, REJECTED, or already-past bookings before mutating them, allowing guests to be added and CONFIRMED invitations to be sent for inactive events; the new action is also included in the actions rendered for past confirmed bookings. Validate booking status and timing before the write and hide the action for ineligible bookings.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:158-163

EventManager uses attendee credentials instead of the organizer's — Build the manager from the organizer/`booking.user` credentials already associated with the booking.

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

Calendar update failures are discarded when adding guests — Calendar update failures are discarded: `updateEvent` catches provider rejections and returns `success: false`, while `updateCalendarAttendees` returns no results, so this handler sends emails and returns success with a stale calendar after the database insert. Return the update results from EventManager and inspect them here, with an explicit recovery path for failed updates.

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

sendAddGuestsEmails ignores event-type host and attendee email settings — `sendAddGuestsEmails` unconditionally sends host and attendee messages and has no event-type metadata parameter, so `disableStandardEmails.all.host` and `disableStandardEmails.all.attendee` are ignored even though the handler has that metadata available. Thread the metadata into this function and apply the same host/attendee guards used by the neighboring email senders.

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

Unbounded guest additions allow excessive database and email work — The guests array has no size bound, but every accepted address drives attendee insertion and translation work and the resulting full attendee list drives calendar updates and concurrent email fanout. An authorized attendee can therefore force unbounded database and email work in one request or across repeated additions; enforce reasonable per-request and per-booking guest caps before inserting or sending.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:124-147

The `CalendarEvent` passed to `sendAddGuestsEmails` never populates `team`, so its… — Load the event type's team members and populate `evt.team` before sending so team bookings notify the intended hosts.

mediumbugpackages/ui/form/MultiEmail.tsx:46

Hard-coded tooltip text bypasses localization — The tooltip content is hard-coded as English `"Remove email"`, bypassing the translation mechanism used by the surrounding UI (and `t` is already available in this component). Users of other locales will still see this tooltip in English; pass a translated string instead.

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

Calendar update failures leave guest additions partially committed — The attendee rows are committed before this awaited external calendar update, and a rejection here has no rollback or compensation. The client receives an error and emails are skipped even though the guests remain persisted; a retry then finds no new unique guests and cannot complete the missed work.

mediumbugpackages/emails/templates/organizer-add-guests-email.ts:28

Unordered attendees can put a blank guest name in the organizer subject — This assumes `attendees[0]` is the booking's named primary attendee, but the handler builds this array from a Prisma `include` with no `orderBy`, so its order is not guaranteed. A newly added guest can be first, and those guests are created with an empty name, producing a blank (or otherwise arbitrary) attendee name in the organizer's subject.

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

Case-sensitive attendee matching allows duplicate guest attendees — Existing-attendee deduplication uses case-sensitive `guest === attendee.email`. A case variant of an already registered attendee email passes this filter and can create a second attendee record for the same mailbox, causing duplicate calendar/email recipients.

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

Team admin permission check incorrectly requires ownership — `isTeamAdmin` already accepts both ADMIN and OWNER, but ANDing it with `isTeamOwner` reduces this permission to owners only, so non-attendee team admins receive FORBIDDEN despite the bookings UI treating them as authorized. Use `isTeamAdmin` alone or OR the two role checks.

mediumbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:70-77

Mixed-case guest emails bypass the blacklist — Blacklist values are normalized to lowercase, but each incoming `guest` is compared without the same normalization. Since the email validator preserves case, an address such as `Blocked@Example.com` bypasses a configured `blocked@example.com` blacklist entry and is added.

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

Concurrent guest additions can create duplicate attendees — The existing-attendee check and insertion are a non-atomic check-then-act sequence. Two concurrent requests for the same new guest can both read the booking before either update commits and then both insert that guest.

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

Duplicate guest emails can create duplicate attendees and invitations — `uniqueGuests` filters existing attendees but never deduplicates the request itself, so a direct request containing the same new address twice inserts duplicate Attendee rows and sends duplicate invitations; the Attendee model has no booking/email unique constraint to stop this. Deduplicate normalized addresses before `createMany` and enforce booking/email uniqueness atomically to also close concurrent-request duplicates. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:3-6`

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

Mailer receives raw guests and misclassifies existing attendees — The mailer receives raw `guests` rather than `uniqueGuests`, so an existing attendee included in a mixed request is misclassified as newly added and receives `AttendeeScheduledEmail` instead of the add-guests notification despite not being inserted. Pass `uniqueGuests` to `sendAddGuestsEmails`.

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.
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.
mediumsendAddGuestsEmails ignores the event type's disableStandardEmails settings, so hosts and attendees receive add-guests emails even when standard emails are disabled.

Gold bugs missed (2)

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