DeepSeek V4 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 Opus 5.5.

Gold bugs found
8 of 18
Comments published
10
Comments matching a bug
8
Comments not matching
2
Cost of this PR
$1.243

Published comments (10)

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

isTeamAdminOrOwner uses && so team admins are denied adding guests — `isTeamAdmin` already covers owners, so `&&` makes this true only for owners and denies team admins with a `FORBIDDEN` error. Change the operator to `||` so non-owner admins can add guests as intended.

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

Normalize guest emails to lowercase before blacklist and duplicate checks — Case differences allow a blacklisted address to bypass the filter and an existing attendee to be re-added as a new row. Normalize `guest`, `attendee.email`, and the blacklist entries to lowercase before both comparisons.

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:58-61

Add guests 500s for team/collective bookings when booking.userId is null — Coercing a nullable `userId` to `0` makes `findFirstOrThrow` throw and return a 500 for team or collective bookings. Fall back to `booking.eventType?.userId` or `user.id` instead of querying id 0.

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

Unbounded guests array permits email fanout resource exhaustion — A single request can submit thousands of emails, each triggering a DB insert, translation lookup, and outgoing email. Cap `guests` with `.max(...)` or add a rate limit to prevent email-fanout exhaustion.

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

sendAddGuestsEmails ignores disableStandardEmails metadata — Event types configured with `disableStandardEmails` still send organizer and attendee emails from this function because the metadata check is missing. Thread `booking.eventType.metadata` into `sendAddGuestsEmails` and gate the loops like `sendLocationChangeEmails` does.

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

AddGuestsDialog leaves isInvalidEmail true after success or dialog open — After a failed attempt, a successful add leaves `isInvalidEmail` true, so reopening the dialog still shows the stale error. Reset `setIsInvalidEmail(false)` in `onSuccess` and when the dialog opens.

mediumbugapps/web/components/dialog/AddGuestsDialog.tsx:42-45

Error toast can show 'undefined: ...' and bypasses fallback — Users can see `undefined: ...` when `err.data?.code` is absent, and the truthy interpolation makes the localized fallback unreachable. Show `t("unable_to_add_guests")` directly instead of prefixing raw TRPC error codes.

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

Missing evt.team prevents team member add-guest emails — Team-member emails are skipped because `CalendarEvent.team` isn't populated here, so the branch in `sendAddGuestsEmails` never runs. Include the `eventType.team` relation in the Prisma query and set `evt.team` from it. **Also found in:** - `packages/emails/email-manager.ts:531-537`

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

Add server-side uniqueness validation for guests array — Duplicates inside the input pass validation and `uniqueGuests` doesn't catch them, so `createMany` can insert repeated attendee rows. Add a `.refine` check for unique emails in the schema or dedupe in the handler.

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

sendAddGuestsEmails misclassifies existing attendees as new guests — Existing attendees whose email also appears in the raw input get the wrong email template because this branch trusts `newGuests`. Pass the filtered `uniqueGuests` from the handler so the parameter reflects actual additions. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168-168` - `packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:167-168`

Gold bugs found (8)

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

Gold bugs missed (10)

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