DeepSeek V4.1 Flash · 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
5 of 8
Comments published
10
Comments matching a bug
5
Comments not matching
5
Cost of this PR
$0.251

Published comments (10)

highbugpackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:158-165

addGuests updates calendar with requesting user's credentials — Calendar updates run with credentials that never created the event, so the organizer's invites are never updated when a team owner or attendee adds guests. Build `EventManager` from `booking.user`'s credentials, as the seat flow in `createNewSeat.ts` does.

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

addGuests handler throws unhandled P2025 when booking.userId is null — A null `booking.userId` makes id 0 throw P2025, surfacing as an unhandled 500 instead of a TRPCError. Throw an explicit TRPCError when `booking.userId` is null before querying.

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

isTeamAdminOrOwner uses && so team admins are wrongly denied access — `isTeamAdmin` already covers ADMIN and OWNER, so combining with `&&` reduces `isTeamAdminOrOwner` to owner-only and rejects team admins. Use `||`, or just `await isTeamAdmin(...)`.

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

Blacklisted guest emails bypassed via case and plus aliases — Comparing `guest` raw against lowercased `blacklistedGuestEmails` lets `Blocked@Example.com` and plus aliases bypass the blacklist, so a low-privilege attendee can inject blocked addresses. Lowercase the guest and reuse `extractBaseEmail` before comparing.

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

Unbounded `guests` array allows mass inserts and email fanout per request — A single caller can submit thousands of addresses, triggering as many inserts and outbound emails per request. Cap `guests` with `.max(...)` and reject oversized input.

mediumsecuritypackages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:52-56

Guest attendees can add arbitrary attendees to a booking — Any existing attendee, not just the organizer or admin, can inject arbitrary third parties into the organizer's calendar event and trigger invites without consent. Drop the `isAttendee` branch or gate attendee additions behind an organizer setting.

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

Guest emails are not deduplicated before createMany — `uniqueGuests` never dedupes within the incoming `guests` array, so duplicates reach `createMany` and produce duplicate rows or a constraint error. Dedupe the input server-side, since the schema has no uniqueness refinement.

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

sendAddGuestsEmails gets raw guests instead of the computed uniqueGuests — Passing raw `guests` makes `sendAddGuestsEmails` classify existing attendees as new, sending duplicate confirmations instead of the added-guests notice. Pass `uniqueGuests` so producer and consumer agree on what counts as a new guest. **Also found in:** - `packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:165-168`

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

Duplicate guest added when email casing differs from existing attendee — The case-sensitive `attendee.email` check lets `Foo@Example.com` through when `foo@example.com` already attends, creating a duplicate row and invite. Lowercase both sides in the comparison, matching `blacklistedGuestEmails`.

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

Error toast leaks raw server error code and message to user — Raw server codes and messages, including Prisma and provider errors from `addGuests`, leak to the user, and this expression is always truthy so the fallback never fires. Show a generic localized message and log the code for server-side diagnostics.

Gold bugs found (5)

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

Gold bugs missed (3)

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