GLM-5.3 Flash · 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
6 of 18
Comments published
8
Comments matching a bug
6
Comments not matching
2
Cost of this PR
$0.093

Published comments (8)

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

isTeamAdminOrOwner uses &&, collapsing admin check to owner-only — Team admins who aren't owners get FORBIDDEN and can't add guests, because `isTeamAdmin` already matches ADMIN and OWNER roles, making the `&&` an owner-only check. Join the two calls with `||` instead.

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:99-104

Adding guests bypasses seat capacity checks and creates no BookingSeat rows — Attendees are inserted without checking remaining capacity or creating `BookingSeat` rows, so seat-limited event types can be overbooked and added guests have no seat record. Validate remaining capacity before inserting and create matching `BookingSeat` rows.

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

Guest email comparison is case-sensitive, letting blacklist and dedup checks be bypassed — A case variant like `Foo@x.com` bypasses a `foo@x.com` blacklist entry and slips through dedup against existing attendees, producing duplicate attendee rows and invites. Normalize both sides of both checks with `.toLowerCase()`.

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

Unbounded guests array allows mass email spam and resource exhaustion — A single request can insert thousands of attendee rows and fan out that many emails, letting the API be abused as a spam relay. Add an upper bound like `.max(20)` to the `guests` array.

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

Guests can be added to non-confirmed bookings via addGuests mutation — Guests land on CANCELLED, REJECTED, or PENDING bookings and receive a confirmed ics email for an event that isn't accepted, a state the UI never allows. Reject the mutation unless `booking.status` is ACCEPTED.

mediumbugpackages/emails/email-manager.ts:531-537

Team-member notification loop in sendAddGuestsEmails is unreachable — `calendarEvent.team?.members` is always undefined because the only caller builds its `CalendarEvent` without a `team` property, so team members never receive this email. Populate `evt.team` from the booking's event type, or drop the dead branch.

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

onSuccess does not reset isInvalidEmail, so error banner persists across dialog opens — After one failed validation, the error banner stays set and shows again the next time the dialog opens for unrelated input. Reset `isInvalidEmail` in `onSuccess`, as the cancel button already does.

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

sendAddGuestsEmails receives raw guests instead of uniqueGuests — Pre-existing attendees filtered out of the insert match in email-manager.ts and receive a full re-confirmation email instead of the intended guests-added notice. Pass `uniqueGuests` as the second argument.

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

mediumThe server never deduplicates the guests array, so a request with the same email twice inserts duplicate attendee rows for the booking.
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.
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).
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.