Team admin or owner check incorrectly requires both roles — The `&&` makes the check pass only for owners, so non-owner team admins are rejected with FORBIDDEN. Use `||` instead so either role satisfies the condition.
Blacklist comparison is case-sensitive, so blocked emails with uppercase pass — Uppercase variants of blocked emails bypass the filter because `guest` is compared case-sensitively. Normalize it with `guest.toLowerCase()` before the `includes` check.
mediumbugpackages/emails/email-manager.ts:531-537
Team members never receive organizer add guests email because team is not populated — `calendarEvent.team?.members` is always undefined because `addGuestsHandler` never populates `team` on the event. Set the team name, members, and id on the CalendarEvent so this loop runs.
Duplicate guest emails result in duplicate attendee rows — Duplicates in the submitted list pass through `uniqueGuests` unchanged and create duplicate attendee rows via `createMany`. Wrap `guests` in `new Set()` before filtering.
sendAddGuestsEmails uses raw guests instead of uniqueGuests — Using the raw `guests` here sends a full invitation to emails that were already attendees. Pass `uniqueGuests` so only newly added guests receive the `AttendeeAddGuestsEmail` notification.
Gold bugs found (4)
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.
Gold bugs missed (14)
highAttendee authorization and existing-attendee dedup compare emails case-sensitively, so an attendee with differently-cased stored email is FORBIDDEN and a case-variant of an existing attendee is added again.
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.
highClaims a failing calendar update at addGuests.handler.ts:165 aborts the mutation after guests are persisted; the calendar update path already swallows provider errors.
mediumThe guests array has no server-side size limit, so any authorized caller, including an attendee, can add thousands of guests and trigger an unbounded batch of inserts and emails.
mediumAfter a validation failure followed by a successful add, isInvalidEmail stays true, so the stale emails_must_be_unique_valid error shows the next time the dialog is opened.
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).
highaddGuests does not check the booking status, so guests can be added to cancelled or rejected bookings, which updates calendars and emails invitations for events that no longer exist.
lowThe addGuests FORBIDDEN error uses the translation key you_do_not_have_permission, which is missing from the locale files, so the dialog shows the raw key to users.
mediumaddGuestsHandler fetches the organizer with findFirstOrThrow on booking.userId || 0; bookings with a null userId make the lookup throw an unhandled Prisma error, returned as a 500 instead of a handled TRPCError.
mediumsendAddGuestsEmails builds attendee emails without showAttendees, so for seated events the email hides other attendees even when seatsShowAttendees is enabled.
mediumClaimed: different errors for unknown vs unauthorized booking ids let any authenticated user enumerate valid booking ids.
mediumThe add-guests action and handler ignore eventType.disableGuests and seatsPerTimeSlot, so guests can be added to events where guests are disabled and to seated events without a seat record.