Kimi K3.1 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 Haiku 5.5.
- Gold bugs found
- 6 of 8
- Comments published
- 16
- Comments matching a bug
- 6
- Comments not matching
- 10
- Cost of this PR
- $2.877
Published comments (16)
Guest insertion bypasses seat capacity and bookingSeat requirements — This unconditional attendee insertion also applies when `eventType.seatsPerTimeSlot` is set, bypassing the seat-capacity check and creating attendees without the required `bookingSeat` relation even though seated events disable guests. Reject seated bookings here or delegate to the seated-booking flow that checks capacity and creates the seat reference.
Add Guests remains available for cancelled, rejected, and past bookings — After authorization, the handler never rejects CANCELLED, REJECTED, or already-past bookings before mutating them, allowing guests to be added and CONFIRMED invitations to be sent for inactive events; the new action is also included in the actions rendered for past confirmed bookings. Validate booking status and timing before the write and hide the action for ineligible bookings.
EventManager uses attendee credentials instead of the organizer's — Build the manager from the organizer/`booking.user` credentials already associated with the booking.
Calendar update failures are discarded when adding guests — Calendar update failures are discarded: `updateEvent` catches provider rejections and returns `success: false`, while `updateCalendarAttendees` returns no results, so this handler sends emails and returns success with a stale calendar after the database insert. Return the update results from EventManager and inspect them here, with an explicit recovery path for failed updates.
sendAddGuestsEmails ignores event-type host and attendee email settings — `sendAddGuestsEmails` unconditionally sends host and attendee messages and has no event-type metadata parameter, so `disableStandardEmails.all.host` and `disableStandardEmails.all.attendee` are ignored even though the handler has that metadata available. Thread the metadata into this function and apply the same host/attendee guards used by the neighboring email senders.
Unbounded guest additions allow excessive database and email work — The guests array has no size bound, but every accepted address drives attendee insertion and translation work and the resulting full attendee list drives calendar updates and concurrent email fanout. An authorized attendee can therefore force unbounded database and email work in one request or across repeated additions; enforce reasonable per-request and per-booking guest caps before inserting or sending.
The `CalendarEvent` passed to `sendAddGuestsEmails` never populates `team`, so its… — Load the event type's team members and populate `evt.team` before sending so team bookings notify the intended hosts.
Hard-coded tooltip text bypasses localization — The tooltip content is hard-coded as English `"Remove email"`, bypassing the translation mechanism used by the surrounding UI (and `t` is already available in this component). Users of other locales will still see this tooltip in English; pass a translated string instead.
Calendar update failures leave guest additions partially committed — The attendee rows are committed before this awaited external calendar update, and a rejection here has no rollback or compensation. The client receives an error and emails are skipped even though the guests remain persisted; a retry then finds no new unique guests and cannot complete the missed work.
Unordered attendees can put a blank guest name in the organizer subject — This assumes `attendees[0]` is the booking's named primary attendee, but the handler builds this array from a Prisma `include` with no `orderBy`, so its order is not guaranteed. A newly added guest can be first, and those guests are created with an empty name, producing a blank (or otherwise arbitrary) attendee name in the organizer's subject.
Case-sensitive attendee matching allows duplicate guest attendees — Existing-attendee deduplication uses case-sensitive `guest === attendee.email`. A case variant of an already registered attendee email passes this filter and can create a second attendee record for the same mailbox, causing duplicate calendar/email recipients.
Team admin permission check incorrectly requires ownership — `isTeamAdmin` already accepts both ADMIN and OWNER, but ANDing it with `isTeamOwner` reduces this permission to owners only, so non-attendee team admins receive FORBIDDEN despite the bookings UI treating them as authorized. Use `isTeamAdmin` alone or OR the two role checks.
Mixed-case guest emails bypass the blacklist — Blacklist values are normalized to lowercase, but each incoming `guest` is compared without the same normalization. Since the email validator preserves case, an address such as `Blocked@Example.com` bypasses a configured `blocked@example.com` blacklist entry and is added.
Concurrent guest additions can create duplicate attendees — The existing-attendee check and insertion are a non-atomic check-then-act sequence. Two concurrent requests for the same new guest can both read the booking before either update commits and then both insert that guest.
Duplicate guest emails can create duplicate attendees and invitations — `uniqueGuests` filters existing attendees but never deduplicates the request itself, so a direct request containing the same new address twice inserts duplicate Attendee rows and sends duplicate invitations; the Attendee model has no booking/email unique constraint to stop this. Deduplicate normalized addresses before `createMany` and enforce booking/email uniqueness atomically to also close concurrent-request duplicates. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:3-6`
Mailer receives raw guests and misclassifies existing attendees — The mailer receives raw `guests` rather than `uniqueGuests`, so an existing attendee included in a mixed request is misclassified as newly added and receives `AttendeeScheduledEmail` instead of the add-guests notification despite not being inserted. Pass `uniqueGuests` to `sendAddGuestsEmails`.