MiniMax M3 · 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 Haiku 5.5.

Gold bugs found
3 of 8
Comments published
8
Comments matching a bug
3
Comments not matching
5
Cost of this PR
$0.274

Published comments (8)

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

isTeamAdminOrOwner requires OWNER role due to redundant AND — `isTeamAdmin` already covers ADMIN and OWNER, so ANDing it with `isTeamOwner` collapses the gate to OWNER-only, wrongly blocking ADMIN team members in `addGuests.handler.ts`. Drop `isTeamOwner` (matching other handlers) so the name `isTeamAdminOrOwner` matches the behavior.

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

Case-sensitivity bypass: guest blacklist not compared case-insensitively — `blacklistedGuestEmails` is lowercased but compared against raw `guest`, so `ATTACKER@BAD.COM` bypasses a stored `attacker@bad.com` and the user gets the invite. Lowercase `guest` (or the whole `guests` array) before the `includes` check.

mediumbugpackages/emails/templates/organizer-add-guests-email.ts:26-30

OrganizerAddGuestsEmail subject throws when attendees is empty — Reading `this.calEvent.attendees[0].name` throws when `attendees` is empty, aborting the organizer email. Guard it with optional chaining and fall back to `this.calEvent.organizer.name` (or team name) so the subject always renders.

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

onSuccess branch fails to reset stale isInvalidEmail state — A stale `isInvalidEmail` survives dialog reopen because `onSuccess` never clears it, so users see a leftover red banner over an empty input. Add `setIsInvalidEmail(false)` inside `onSuccess` to mirror the cancel-button reset.

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

BAD_REQUEST message says emails_must_be_unique_valid when cause is 'no new guests remain' — Throwing `emails_must_be_unique_valid` when every guest was already present mislabels the failure. Use a key like `no_new_guests_to_add` so the i18n copy matches the actual bad-request cause.

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

TOCTOU race in addGuests allows duplicate attendees and bypasses blacklist — Concurrent calls slip past `booking.attendees` filtering and the non-transactional `createMany` writes duplicate rows, and case-variant emails bypass the exact-match check. Wrap the filter and insert in `prisma.$transaction` (re-querying attendees inside it), add a `@@unique([bookingId, email])` constraint, and compare lowercased emails.

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

sendAddGuestsEmails invoked with raw input guests not uniqueGuests — `sendAddGuestsEmails(evt, guests)` passes the unfiltered input, so the email manager's `newGuests.includes` check sees attendees who weren't actually added. Pass `uniqueGuests` instead so notifications match the booking update.

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

Duplicate attendee dedupe ignores email case-insensitivity — Strict equality between `guest` and `attendee.email` lets `USER@EXAMPLE.COM` duplicate `user@example.com`, producing extra attendee rows and duplicate emails. Normalise with `guest.toLowerCase() === attendee.email.toLowerCase()` before the dedupe filter.

Gold bugs found (3)

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.

Gold bugs missed (5)

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