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