GLM-5.3 · 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
4 of 8
Comments published
8
Comments matching a bug
4
Comments not matching
4
Cost of this PR
$0.912

Published comments (8)

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

Team permission check uses && so admins (non-owners) are denied adding guests — Team admins get `FORBIDDEN` on their own team's booking because `isTeamAdmin && isTeamOwner` demands both roles. Use `||` — or just `isTeamAdmin`, which already returns true for ADMIN or OWNER.

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

Guest emails bypass blacklist and duplicate check due to case-sensitive comparison — A mixed-case guest like `Spam@Example.com` slips past the lowercased `blacklistedGuestEmails` and receives the full booking details and video link. Compare against `guest.toLowerCase()`, and normalize the `booking.attendees` duplicate check the same way.

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:26-44

No booking status check allows adding guests to cancelled/rejected bookings — Attendee rows are created, CONFIRMED ics attachments are emailed, and calendar updates run against deleted events, since `booking.status` is never checked. Throw `BAD_REQUEST` unless the status is `ACCEPTED`, before any state changes.

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

Guests array is not deduplicated, allowing duplicate Attendee rows — Submitting the same email twice in `guests` inserts two identical Attendee rows — the model has no unique constraint — causing duplicate emails and calendar entries. Dedupe case-insensitively before `createMany`; the server schema in `addGuests.schema.ts` drops the client-side uniqueness refine.

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

sendAddGuestsEmails receives raw guests, re-sending scheduled email to existing attendees — An existing attendee who is re-submitted still gets `AttendeeScheduledEmail` instead of the add-guests notification, since `sendAddGuestsEmails` in `email-manager.ts` treats raw `guests` as new. Pass `uniqueGuests` so only added guests are notified.

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

Unbounded `guests` array enables resource exhaustion and mail bombing — One authorized request with thousands of emails triggers an unbounded `createMany`, a huge email fanout, and a bloated calendar update — a repeatable mail-bombing vector from any attendee account. Bound the `guests` array in `ZAddGuestsInputSchema` with `.max(25)`.

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

evt CalendarEvent never sets team, so team members never get add-guests emails — Team members silently miss the add-guests notification: `sendAddGuestsEmails` in `email-manager.ts` only notifies when `calEvent.team?.members` is populated, leaving that loop dead code. Populate `evt.team` from `booking.eventType.team` with its members, as `handleCancelBooking.ts` does.

mediumbugapps/web/components/dialog/AddGuestsDialog.tsx:35-46

Stale validation error banner reappears when dialog is reopened — Since the dialog stays mounted in `BookingListItem`, one failed validation makes the error banner reappear on every reopen, even after a successful add. Clear `isInvalidEmail` in `onSuccess`, and reset both it and `multiEmailValue` when closing via `onOpenChange`.

Gold bugs found (4)

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.

Gold bugs missed (4)

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