Kimi K3.1 Pro · 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
6 of 8
Comments published
12
Comments matching a bug
6
Comments not matching
6
Cost of this PR
$1.607

Published comments (12)

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

Team admin check incorrectly requires ownership — Non-owner team admins are rejected because ANDing `isTeamAdmin` with `isTeamOwner` reduces `isTeamAdminOrOwner` to owners, even though `isTeamAdmin` already includes both roles. Use `isTeamAdmin` alone or OR the two checks so admins can add guests.

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

Duplicate guest emails create duplicate attendees and notifications — Repeated addresses within `guests` survive this filter, so `createMany` receives both entries, creating duplicate attendee records and notifications. Deduplicate `guests` server-side before filtering against existing attendees and blacklist entries.

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

Blacklist check is bypassable with case changes and plus tags — Because only `blacklistedGuestEmails` is lowercased, `Blocked@example.com` or `blocked+tag@example.com` can bypass `blocked@example.com` and receive an invitation. Compare lowercase `extractBaseEmail(guest)` values against the blacklist, matching the normal booking flow.

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

EventManager uses requester credentials instead of the booking organizer's — Attendee and team-admin requests pass the requester's credentials to `EventManager`, so references without `credentialId` can skip the update or use the wrong account, leaving guests off the organizer's calendar. Initialize it with `booking.user` and `getUsersCredentials(booking.user)`, rejecting a missing organizer.

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

Mixed guest requests email existing attendees as newly added guests — Passing `guests` to `sendAddGuestsEmails` makes existing attendees in mixed requests look newly added, so they receive `AttendeeScheduledEmail` despite not being inserted. Pass `uniqueGuests` instead so only attendees actually added receive the new-guest scheduled email.

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

Guests can be added to cancelled or rejected bookings — Reject inactive statuses before `prisma.booking.update` inserts attendees.

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

Missing team data prevents team-member guest notifications — The `CalendarEvent` built for `sendAddGuestsEmails` omits `team`, so its team-member notification loop never runs, even for team bookings. Load the event type's team and accepted members, then populate `evt.team` before sending notifications.

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

Unbounded guest array can trigger excessive database and email work — An unbounded `guests` array lets one authorized request create thousands of rows and outbound messages, exhausting database and mail-provider quotas. Add a conservative `.max(100)` limit to the schema and enforce it server-side.

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

Attendees can add guests when disableGuests is enabled — Reject guest additions when that flag is set, and hide the corresponding booking action in the UI.

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

Add-guest emails ignore event-type standard email suppression — Host and attendee notifications still go out when `eventType.metadata.disableStandardEmails.all` suppresses standard emails. Accept the metadata in `sendAddGuestsEmails`, gate both recipient branches with the location-change flow's helpers, and pass `booking.eventType?.metadata` from `addGuestsHandler`.

mediumbugpackages/emails/email-manager.ts:539-546

Add-guests attendee emails omit showAttendees for seated events — Without the `showAttendees` argument, `AttendeeScheduledEmail` strips other attendees whenever `seatsPerTimeSlot` is set, even if `seatsShowAttendees` is true. Pass `calendarEvent.seatsShowAttendees` as the third argument to both `AttendeeScheduledEmail` and `AttendeeAddGuestsEmail`.

mediumbugapps/web/components/dialog/AddGuestsDialog.tsx:36-40

Successful submission leaves a stale email validation error — Call `setIsInvalidEmail(false)` in `onSuccess`, as cancellation already does.

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