GLM-5.3 Flash · 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 Opus 5.5.

Gold bugs found
9 of 18
Comments published
10
Comments matching a bug
9
Comments not matching
1
Cost of this PR
$0.191

Published comments (10)

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

Adding guests to seated bookings overbooks slots and skips BookingSeat creation — Attendees get created without seats, so they can't be managed or cancelled per-seat and become invisible in seat-based views. Reject seated bookings early, as the fix does, or create `BookingSeat` rows after checking remaining capacity.

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

EventManager built with caller's credentials instead of organizer's — When the caller is an attendee or team admin, their credentials get used against the organizer's external calendar event and the update fails, so new guests never appear on it. Build the `EventManager` from `booking.user` instead of `ctx.user`.

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

Team admins rejected: isTeamAdmin && isTeamOwner only passes for owners — Team admins who are neither organizer nor attendee get a FORBIDDEN error, contradicting the intent of `isTeamAdminOrOwner`. Since `isTeamAdmin` already covers admins and owners, combine the checks with `||` instead of `&&`.

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

Guest emails with uppercase characters bypass the guest email blocklist — A guest like 'Spam@x.com' gets added and emailed despite being blocked. Compare `guest.toLowerCase()` against `blacklistedGuestEmails`, matching `checkIfBookerEmailIsBlocked` which lowercases both sides.

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

Team bookings build CalendarEvent without team, so team hosts miss guest emails — Additional team-member hosts never receive the guests-added email, and subjects fall back to the organizer's personal name. Populate `team` on `evt` from the booking's event type team, fetching its name and accepted members as `handleNewBooking` does.

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

Unbounded guests array allows mass attendee/email abuse — A single request can insert thousands of attendee rows and send mass emails to arbitrary third parties through Cal.com's mail infrastructure. Cap the `guests` array with `.max(10)` and consider a per-request limit in the handler.

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

isInvalidEmail banner never cleared on success, persists across dialog opens — The stale 'Emails must be unique and valid' banner reappears the next time the dialog opens after a successful add. Reset it with `setIsInvalidEmail(false)` in `onSuccess` and at the start of a passing validation in `handleAdd`.

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

Booking-ID oracle: distinct NOT_FOUND vs FORBIDDEN errors leak booking existence — Any authenticated user can probe this mutation to enumerate valid booking IDs across the system by comparing the two error responses. Scope the lookup to bookings the caller can access, or return `booking_not_found` for unauthorized IDs too.

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

Duplicate emails in guests array create duplicate attendee rows — Duplicate attendee rows cause repeated guest emails and duplicate calendar updates, even from concurrent requests. Dedupe the `guests` input case-insensitively in the handler as shown, or add a unique constraint on `Attendee`.

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

sendAddGuestsEmails receives raw guests instead of filtered uniqueGuests — Guests already on the booking receive a fresh 'confirmed' invitation with an .ics file even though nothing changed for them. Pass `uniqueGuests` instead of `guests` to `sendAddGuestsEmails`.

Gold bugs found (9)

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.
mediumThe guests array has no server-side size limit, so any authorized caller, including an attendee, can add thousands of guests and trigger an unbounded batch of inserts and emails.
mediumAfter a validation failure followed by a successful add, isInvalidEmail stays true, so the stale emails_must_be_unique_valid error shows the next time the dialog is opened.
mediumClaimed: different errors for unknown vs unauthorized booking ids let any authenticated user enumerate valid booking ids.
mediumThe add-guests action and handler ignore eventType.disableGuests and seatsPerTimeSlot, so guests can be added to events where guests are disabled and to seated events without a seat record.

Gold bugs missed (9)

highAttendee authorization and existing-attendee dedup compare emails case-sensitively, so an attendee with differently-cased stored email is FORBIDDEN and a case-variant of an existing attendee is added again.
highClaims a failing calendar update at addGuests.handler.ts:165 aborts the mutation after guests are persisted; the calendar update path already swallows provider errors.
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).
highaddGuests does not check the booking status, so guests can be added to cancelled or rejected bookings, which updates calendars and emails invitations for events that no longer exist.
lowThe addGuests FORBIDDEN error uses the translation key you_do_not_have_permission, which is missing from the locale files, so the dialog shows the raw key to users.
mediumaddGuestsHandler fetches the organizer with findFirstOrThrow on booking.userId || 0; bookings with a null userId make the lookup throw an unhandled Prisma error, returned as a 500 instead of a handled TRPCError.
mediumsendAddGuestsEmails builds attendee emails without showAttendees, so for seated events the email hides other attendees even when seatsShowAttendees is enabled.