Amazon Ergo 1.0 · 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 Opus 5.5.

Gold bugs found
7 of 18
Comments published
7
Comments matching a bug
7
Comments not matching
0
Cost of this PR
$1.544

Published comments (7)

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

Team admins are denied by the && permission check — Team admins can see the action but then receive `FORBIDDEN`, because `isTeamAdminOrOwner` is true only for owners. Use `||` so the check matches `isUserTeamAdminOrOwner`, or rely on `isTeamAdmin` alone.

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

Blacklisted guests can bypass the check with different casing — A differently cased address such as `Blocked@Example.com` bypasses `BLACKLISTED_GUEST_EMAILS`, because `includes(guest)` is case-sensitive. Normalize `guest` with `toLowerCase()` before the blacklist and attendee comparisons, as in `checkIfBookerEmailIsBlocked`.

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

addGuests does not reject CANCELLED or REJECTED bookings — Direct calls can add attendees, update the calendar event, and send ICS emails for `CANCELLED` or `REJECTED` bookings because `booking.status` is never checked. Reject bookings whose status is not `ACCEPTED` server-side rather than relying on the UI.

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

Submitted guests array is not deduped, creating duplicate attendee rows — `uniqueGuests` only excludes existing attendees and blacklisted addresses, so duplicate entries in a direct API request create duplicate attendee rows and emails. Dedupe `guests` with `Array.from(new Set(guests))` before filtering.

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

Raw guest input sends duplicate confirmations to existing attendees — Existing attendees named in the request receive a second full booking confirmation because `sendAddGuestsEmails(evt, guests)` uses the raw input to select `AttendeeScheduledEmail`. Pass `uniqueGuests` so only newly added guests receive that email.

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

Add-guests emails ignore event-type email disable settings — Event types that disable standard host or attendee emails still send add-guests notifications and ICS files because `sendAddGuestsEmails` ignores their metadata. Pass the event type metadata and gate organizer and attendee emails with `eventTypeDisableHostEmail` and `eventTypeDisableAttendeeEmail`.

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

Unbounded guests array allows oversized add-guest requests — An attendee can submit an unbounded `guests` array, causing oversized writes, calendar updates, and one email per guest plus notifications to existing attendees and team members. Cap it with `.max(100)` and consider rate limiting the mutation.

Gold bugs found (7)

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

Gold bugs missed (11)

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