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