crbench//

← all cases

Add guest management functionality to existing bookings

Tier 2 hard typescript · local · real merged PR from calcom/cal.com #14740

Ground-truth defects

d1 · security · medium
Case sensitivity bypass in email blacklist
d2 · security · medium
The logic for checking team admin/owner permissions is incorrect. This condition uses AND (&&) which requires both isTeamAdmin AND isTeamOwner to be true, but it should use OR (||) since a user needs to be either an admin OR an owner to have permission.
d3 · other · medium
This calls the email sender with the original guests, so existing attendees included in the input will be treated as new when sending notifications, leading to incorrect emails.
d4 · other · low
uniqueGuests filters out existing attendees and blacklisted emails but does not deduplicate duplicates within the input; createMany can insert duplicate attendee rows if the client submits repeated emails.
d5 · correctness · medium
`sendAddGuestsEmails` takes no event-type metadata and unconditionally sends to the organizer, every team member and every attendee, while every other booking-lifecycle sender in the same file gates on the helpers that read `disableStandardEmails.all.host` and `.attendee`. The handler already loads the event type, so the metadata is in hand and simply not passed, and an organizer who disabled standard emails still has them sent.

The change under review

diff (truncated — full diff)
diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx
index cfcc5d9abb..1d74398552 100644
--- a/apps/web/components/booking/BookingListItem.tsx
+++ b/apps/web/components/booking/BookingListItem.tsx
@@ -43,6 +43,7 @@ import {
   Tooltip,
 } from "@calcom/ui";
 
+import { AddGuestsDialog } from "@components/dialog/AddGuestsDialog";
 import { ChargeCardDialog } from "@components/dialog/ChargeCardDialog";
 import { EditLocationDialog } from "@components/dialog/EditLocationDialog";
 import { ReassignDialog } from "@components/dialog/ReassignDialog";
@@ -189,6 +190,14 @@ function BookingListItem(booking: BookingItemProps) {
       },
       icon: "map-pin" as const,
     },
+    {
+      id: "add_members",
+      label: t("additional_guests"),
+      onClick: () => {
+        setIsOpenAddGuestsDialog(true);
+      },
+      icon: "user-plus" as const,
+    },
   ];
 
   if (booking.eventType.schedulingType === SchedulingType.ROUND_ROBIN) {
@@ -256,6 +265,7 @@ function BookingListItem(booking: BookingItemProps) {
   const [isOpenRescheduleDialog, setIsOpenRescheduleDialog] = useState(false);
   const [isOpenReassignDialog, setIsOpenReassignDialog] = useState(false);
   const [isOpenSetLocationDialog, setIsOpenLocationDialog] = useState(false);
+  const [isOpenAddGuestsDialog, setIsOpenAddGuestsDialog] = useState(false);
   const setLocationMutation = trpc.viewer.bookings.editLocation.useMutation({
     onSuccess: () => {
       showToast(t("location_updated"), "success");
@@ -344,6 +354,11 @@ function BookingListItem(booking: BookingItemProps) {
         setShowLocationModal={setIsOpenLocationDialog}
         teamId={booking.eventType?.team?.id}
       />
+      <AddGuestsDialog
+        isOpenDialog={isOpenAddGuestsDialog}
+        setIsOpenDialog={setIsOpenAddGuestsDialog}
+        bookingId={booking.id}
+      />
       {booking.paid && booking.payment[0] && (
         <ChargeCardDialog
           isOpenDialog={chargeCardDialogIsOpen}
diff --git a/apps/web/components/dialog/AddGuestsDialog.tsx b/apps/web/components/dialog/AddGuestsDialog.tsx
new file mode 100644
index 0000000000..592b32c886
--- /dev/null
+++ b/apps/web/components/dialog/AddGuestsDialog.tsx
@@ -0,0 +1,107 @@
+import type { Dispatch, SetStateAction } from "react";
+import { useState } from "react";
+import { z } from "zod";
+
+import { useLocale } from "@calcom/lib/hooks/useLocale";
+import { trpc } from "@calcom/trpc/react";
+import {
+  Button,
+  Dialog,
+  DialogContent,
+  DialogFooter,
+  DialogHeader,
+  MultiEmail,
+  Icon,
+  showToast,
+} from "@calcom/ui";
+
+interface IAddGuestsDialog {
+  isOpenDialog: boolean;
+  setIsOpenDialog: Dispatch<SetStateAction<boolean>>;
+  bookingId: number;
+}
+
+export const AddGuestsDialog = (props: IAddGuestsDialog) => {
+  const { t } = useLocale();
+  const ZAddGuestsInputSchema = z.array(z.string().email()).refine((emails) => {
+    const uniqueEmails = new Set(emails);
+    return uniqueEmails.size === emails.length;
+  });
+  const { isOpenDialog, setIsOpenDialog, bookingId } = props;
+  const utils = trpc.useUtils();
+  const [multiEmailValue, setMultiEmailValue] = useState<string[]>([""]);
+  const [isInvalidEmail, setIsInvalidEmail] = useState(false);
+
+  const addGuestsMutation = trpc.viewer.bookings.addGuests.useMutation({
+    onSuccess: async () => {
+      showToast(t("guests_added"), "success");
+      setIsOpenDialog(false);
+      setMultiEmailValue([""]);
+      utils.viewer.bookings.invalidate();
+    },
+    onError: (err) => {
+      const message = `${err.data?.code}: ${t(err.message)}`;
+      showToast(message || t("unable_to_add_guests"), "error");
+    },
+  });
+
+  const handleAdd = () => {
+    if (multiEmailValue.length === 0) {
+      return;
+    }
+    const validationResult = ZAddGuestsInputSchema.safeParse(multiEmailValue);
+    if (validationResult.success) {
+      addGuestsMutation.mutate({ bookingId, guests: multiEmailValue });
+    } else {
+      setIsInvalidEmail(true);
+    }
+  };
+
+  return (
+    <Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}>
+      <DialogContent enableOverflow>
+        <div className="flex flex-row space-x-3">
+          <div className="bg-subtle flex h-10 w-10 flex-shrink-0 justify-center rounded-full ">
+            <Icon name="user-plus" className="m-auto h-6 w-6" />
+          </div>
+          <div className="w-full pt-1">
+            <DialogHeader title={t("additional_guests")} />
+            <MultiEmail
+              label={t("add_emails")}
+              value={multiEmailValue}
+              readOnly={false}
+              setValue={setMultiEmailValue}
+            />
+
+            {isInvalidEmail && (
+              <div className="my-4 flex text-sm text-red-700">
+                <div className="flex-shrink-0">
+                  <Icon name="triangle-alert" className="h-5 w-5" />
+                </div>
+                <div className="ml-3">
+                  <p className="font-medium">{t("emails_must_be_unique_valid")}</p>
+                </div>
+              </div>
+            )}
+
+            <DialogFooter>
+              <Button
+                onClick={() => {
+                  setMultiEmailValue([""]);
+                  setIsInvalidEmail(false);
+                  setIsOpenDialog(false);
+                }}
+                type="button"
+                color="secondary">
+                {t("cancel")}
+              </Button>
+              <Button data-testid="add_members" loading={addGuestsMutation.isPending} onClick={handleAdd}>
+                {t("add")}
+              </Button>
+            </DialogFooter>
+          </div>
+        </div>
+      </DialogContent>
+    </Dialog>
+  );
+};
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index cf77ef8492..3b55274330 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -1119,7 +1119,9 @@
   "impersonating_user_warning": "Impersonating username \"{{user}}\".",
   "impersonating_stop_instructions": "Click here to stop",
   "event_location_changed": "Updated - Your event changed the location",
+  "new_guests_added": "Added - New guests added to your event",
   "location_changed_event_type_subject": "Location Changed: {{eventType}} with {{name}} at {{date}}",
+  "guests_added_event_type_subject": "Guests Added: {{eventType}} with {{name}} at {{date}}",
   "current_location": "Current Location",
   "new_location": "New Location",
   "session": "Session",
@@ -1131,7 +1133,10 @@
   "set_location": "Set Location",
   "update_location": "Update Location",
   "location_updated": "Location updated",
+  "guests_added": "Guests added",
+  "unable_to_add_guests": "Unable to add guests",
   "email_validation_error": "That doesn't look like an email address",
+  "emails_must_be_unique_valid": "Emails must be unique and valid",
   "url_validation_error": "That doesn't look like a URL",
   "place_where_cal_widget_appear": "Place this code in your HTML where you want your {{appName}} widget to appear.",
   "create_update_react_component": "Create or update an existing React component as shown below.",
@@ -2426,6 +2431,7 @@
   "primary": "Primary",
   "make_primary": "Make primary",
   "add_email": "Add Email",
+  "add_emails": "Add Emails",
   "add_email_description": "Add an email address to replace your primary or to use as an alternative email on your event types.",
   "confirm_email": "Confirm your email",
   "scheduler_first_name": "The first name of the person booking",
diff --git a/packages/emails/email-manager.ts b/packages/emails/email-manager.ts
index c756a29c38..85a2a2c219 100644
--- a/packages/emails/email-manager.ts
+++ b/packages/emails/email-manager.ts
@@ -18,6 +18,7 @@ import type { EmailVerifyLink } from "./templates/account-verify-email";
 import AccountVerifyEmail from "./templates/account-verify-email";
 import type { OrganizationNotification } from "./templates/admin-organization-notification";
 import AdminOrganizationNotification from "./templates/admin-organization-notification";
+import AttendeeAddGuestsEmail from "./templates/attendee-add-guests-email";
 import AttendeeAwaitingPaymentEmail from "./templates/attendee-awaiting-payment-email";
 import AttendeeCancelledEmail from "./templates/attendee-cancelled-email";
 import AttendeeCancelledSeatEmail from "./templates/attendee-cancelled-seat-email";
@@ -48,6 +49,7 @@ import type { OrganizationCreation } from "./templates/organization-creation-ema
 import OrganizationCreationEmail from "./templates/organization-creation-email";
 import type { OrganizationEmailVerify } from "./templates/organization-email-verification";
 import OrganizationEmailVerification from "./templates/organization-email-verification";
+import OrganizerAddGuestsEmail from "./templates/organizer-add-guests-email";
 import OrganizerAttendeeCancelledSeatEmail from "./templates/organizer-attendee-cancelled-seat-email";
 import OrganizerCancelledEmail from "./templates/organizer-cancelled-email";
 import OrganizerDailyVideoDownloadRecordingEmail from "./templates/organizer-daily-video-download-recording-email";
@@ -520,6 +522,32 @@ export const sendLocationChangeEmails = async (
 
   await Promise.all(emailsToSend);
 };
+export const sendAddGuestsEmails = async (calEvent: CalendarEvent, newGuests: string[]) => {
+  const calendarEvent = formatCalEvent(calEvent);
+
+  const emailsToSend: Promise<unknown>[] = [];
+  emailsToSend.push(sendEmail(() => new OrganizerAddGuestsEmail({ calEvent: calendarEvent })));
+
+  if (calendarEvent.team?.members) {
+    for (const teamMember of calendarEvent.team.members) {
+      emailsToSend.push(
+        sendEmail(() => new OrganizerAddGuestsEmail({ calEvent: calendarEvent, teamMember }))
+      );
+    }
+  }
+
+  emailsToSend.push(
+    ...calendarEvent.attendees.map((attendee) => {
+      if (newGuests.includes(attendee.email)) {
+        return sendEmail(() => new AttendeeScheduledEmail(calendarEvent, attendee));
+      } else {
+        return sendEmail(() => new AttendeeAddGuestsEmail(calendarEvent, attendee));
+      }
+    })
+  );
+
+  await Promise.all(emailsToSend);
+};
 export const sendFeedbackEmail = async (feedback: Feedback) => {
   await sendEmail(() => new FeedbackEmail(feedback));
 };
diff --git a/packages/emails/src/templates/AttendeeAddGuestsEmail.tsx b/packages/emails/src/templates/AttendeeAddGuestsEmail.tsx
new file mode 100644
index 0000000000..cbc736869b
--- /dev/null
+++ b/packages/emails/src/templates/AttendeeAddGuestsEmail.tsx
@@ -0,0 +1,10 @@
+import { AttendeeScheduledEmail } from "./AttendeeScheduledEmail";
+
+export const AttendeeAddGuestsEmail = (props: React.ComponentProps<typeof AttendeeScheduledEmail>) => (
+  <AttendeeScheduledEmail
+    title="new_guests_added"
+    headerType="calendarCircle"
+    subject="guests_added_event_type_subject"
+    {...props}
+  />
+);
diff --git a/packages/emails/src/templates/OrganizerAddGuestsEmail.tsx b/packages/emails/src/templates/OrganizerAddGuestsEmail.tsx
new file mode 100644
index 0000000000..74171b2270
--- /dev/null
+++ b/packages/emails/src/templates/OrganizerAddGuestsEmail.tsx
@@ -0,0 +1,11 @@
+import { OrganizerScheduledEmail } from "./OrganizerScheduledEmail";
+
+export const OrganizerAddGuestsEmail = (props: React.ComponentProps<typeof OrganizerScheduledEmail>) => (
+  <OrganizerScheduledEmail
+    title="new_guests_added"
+    headerType="calendarCircle"
+    subject="guests_added_event_type_subject"
+    callToAction={null}
+    {...props}
+  />
+);
diff --git a/packages/emails/src/templates/index.ts b/packages/emails/src/templates/index.ts
index fa48848e49..33d32b4894 100644
--- a/packages/emails/src/templates/index.ts
+++ b/packages/emails/src/templates/index.ts
@@ -35,4 +35,6 @@ export { AdminOrganizationNotificationEmail } from "./AdminOrganizationNotificat
 export { BookingRedirectEmailNotification } from "./BookingRedirectEmailNotification";
 export { VerifyEmailChangeEmail } from "./VerifyEmailChangeEmail";
 export { OrganizationCreationEmail } from "./OrganizationCreationEmail";
+export { OrganizerAddGuestsEmail } from "./OrganizerAddGuestsEmail";
+export { AttendeeAddGuestsEmail } from "./AttendeeAddGuestsEmail";
 export { OrganizationAdminNoSlotsEmail } from "./OrganizationAdminNoSlots";
diff --git a/packages/emails/templates/attendee-add-guests-email.ts b/packages/emails/templates/attendee-add-guests-email.ts
new file mode 100644
index 0000000000..155989acbd
--- /dev/null
+++ b/packages/emails/templates/attendee-add-guests-email.ts
@@ -0,0 +1,34 @@
+import { renderEmail } from "../";
+import generateIcsString from "../lib/generateIcsString";
+import AttendeeScheduledEmail from "./attendee-scheduled-email";
+
+export default class AttendeeAddGuestsEmail extends AttendeeScheduledEmail {
+  protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
+    return {
+      icalEvent: {
+        filename: "event.ics",
+        content: generateIcsString({
+          event: this.calEvent,
+          title: this.t("new_guests_added"),
+          subtitle: this.t("emailed_you_and_any_other_attendees"),
+          role: "attendee",
+          status: "CONFIRMED",
+        }),
+        method: "REQUEST",
+      },
+      to: `${this.attendee.name} <${this.attendee.email}>`,
+      from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`,
+      replyTo: this.calEvent.organizer.email,
+      subject: `${this.t("guests_added_event_type_subject", {
+        eventType: this.calEvent.type,
+        name: this.calEvent.team?.name || this.calEvent.organizer.name,
+        date: this.getFormattedDate(),
+      })}`,
+      html: await renderEmail("AttendeeAddGuestsEmail", {
+        calEvent: this.calEvent,
+        attendee: this.attendee,
+      }),
+      text: this.getTextBody("new_guests_added"),
+    };
+  }
+}
diff --git a/packages/emails/templates/organizer-add-guests-email.ts b/packages/emails/templates/organizer-add-guests-email.ts
new file mode 100644
index 0000000000..0a2a9d39b5
--- /dev/null
+++ b/packages/emails/templates/organizer-add-guests-email.ts
@@ -0,0 +1,38 @@
+import { APP_NAME } from "@calcom/lib/constants";
+
+import { renderEmail } from "../";
+import generateIcsString from "../lib/generateIcsString";
+import OrganizerScheduledEmail from "./organizer-scheduled-email";
+
+export default class OrganizerAddGuestsEmail extends OrganizerScheduledEmail {
+  protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
+    const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email];
+
+    return {
+      icalEvent: {
+        filename: "event.ics",
+        content: generateIcsString({
+          event: this.calEvent,
+          title: this.t("new_guests_added"),
+          subtitle: this.t("emailed_you_and_any_other_attendees"),
+          role: "organizer",
+          status: "CONFIRMED",
+        }),
+        method: "REQUEST",
+      },
+      from: `${APP_NAME} <${this.getMailerOptions().from}>`,
+      to: toAddresses.join(","),
+      replyTo: [this.calEvent.organizer.email, ...this.calEvent.attendees.map(({ email }) => email)],
+      subject: `${this.t("guests_added_event_type_subject", {
+        eventType: this.calEvent.type,
+        name: this.calEvent.attendees[0].name,
+        date: this.getFormattedDate(),
+      })}`,
+      html: await renderEmail("OrganizerAddGuestsEmail", {
+        attendee: this.calEvent.organizer,
+        calEvent: this.calEvent,
+      }),
+      text: this.getTextBody("new_guests_added"),
+    };
+  }
+}
diff --git a/packages/trpc/server/routers/viewer/bookings/_router.tsx b/packages/trpc/server/routers/viewer/bookings/_router.tsx
index 7cb7b08682..91cd36ea54 100644
--- a/packages/trpc/server/routers/viewer/bookings/_router.tsx
+++ b/packages/trpc/server/routers/viewer/bookings/_router.tsx
@@ -1,6 +1,7 @@
 import authedProcedure from "../../../procedures/authedProcedure";
 import publicProcedure from "../../../procedures/publicProcedure";
 import { router } from "../../../trpc";
+import { ZAddGuestsInputSchema } from "./addGuests.schema";
 import { ZConfirmInputSchema } from "./confirm.schema";
 import { ZEditLocationInputSchema } from "./editLocation.schema";
 import { ZFindInputSchema } from "./find.schema";
@@ -14,6 +15,7 @@ type BookingsRouterHandlerCache = {
   get?: typeof import("./get.handler").getHandler;
   requestReschedule?: typeof import("./requestReschedule.handler").requestRescheduleHandler;
   editLocation?: typeof import("./editLocation.handler").editLocationHandler;
+  addGuests?: typeof import("./addGuests.handler").addGuestsHandler;
   confirm?: typeof import("./confirm.handler").confirmHandler;
   getBookingAttendees?: typeof import("./getBookingAttendees.handler").getBookingAttendeesHandler;
   find?: typeof import("./find.handler").getHandler;
@@ -74,6 +76,23 @@ export const bookingsRouter = router({
       input,
     });
   }),
+  addGuests: authedProcedure.input(ZAddGuestsInputSchema).mutation(async ({ input, ctx }) => {
+    if (!UNSTABLE_HANDLER_CACHE.addGuests) {
+      UNSTABLE_HANDLER_CACHE.addGuests = await import("./addGuests.handler").then(
+        (mod) => mod.addGuestsHandler
+      );
+    }
+
+    // Unreachable code but required for type safety
+    if (!UNSTABLE_HANDLER_CACHE.addGuests) {
+      throw new Error("Failed to load handler");
+    }
+
+    return UNSTABLE_HANDLER_CACHE.addGuests({
+      ctx,
+      input,
+    });
+  }),
 
   confirm: authedProcedure.input(ZConfirmInputSchema).mutation(async ({ input, ctx }) => {
     if (!UNSTABLE_HANDLER_CACHE.confirm) {
diff --git a/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts b/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts
new file mode 100644
index 0000000000..99fec2cadf
--- /dev/null
+++ b/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts
@@ -0,0 +1,174 @@
+import EventManager from "@calcom/core/EventManager";
+import dayjs from "@calcom/dayjs";
+import { sendAddGuestsEmails } from "@calcom/emails";
+import { parseRecurringEvent } from "@calcom/lib";
+import { getTranslation } from "@calcom/lib/server";
+import { getUsersCredentials } from "@calcom/lib/server/getUsersCredentials";
+import { isTeamAdmin, isTeamOwner } from "@calcom/lib/server/queries/teams";
+import { prisma } from "@calcom/prisma";
+import type { CalendarEvent } from "@calcom/types/Calendar";
+
+import { TRPCError } from "@trpc/server";
+
+import type { TrpcSessionUser } from "../../../trpc";
+import type { TAddGuestsInputSchema } from "./addGuests.schema";
+
+type AddGuestsOptions = {
+  ctx: {
+    user: NonNullable<TrpcSessionUser>;
+  };
+  input: TAddGuestsInputSchema;
+};
+export const addGuestsHandler = async ({ ctx, input }: AddGuestsOptions) => {
+  const { user } = ctx;
+  const { bookingId, guests } = input;
+
+  const booking = await prisma.booking.findFirst({
+    where: {
+      id: bookingId,
+    },
+    include: {
+      attendees: true,
+      eventType: true,
+      destinationCalendar: true,
+      references: true,
+      user: {
+        include: {
+          destinationCalendar: true,
+          credentials: true,
+        },
+      },
+    },
+  });
+
+  if (!booking) throw new TRPCError({ code: "NOT_FOUND", message: "booking_not_found" });
+
+  const isTeamAdminOrOwner =
+    (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) &&
+    (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0));
+
+  const isOrganizer = booking.userId === user.id;
+
+  const isAttendee = !!booking.attendees.find((attendee) => attendee.email === user.email);
+
+  if (!isTeamAdminOrOwner && !isOrganizer && !isAttendee) {
+    throw new TRPCError({ code: "FORBIDDEN", message: "you_do_not_have_permission" });
+  }
+
+  const organizer = await prisma.user.findFirstOrThrow({
+    where: {
+      id: booking.userId || 0,
+    },
+    select: {
+      name: true,
+      email: true,
+      timeZone: true,
+      locale: true,
+    },
+  });
+
+  const blacklistedGuestEmails = process.env.BLACKLISTED_GUEST_EMAILS
+    ? process.env.BLACKLISTED_GUEST_EMAILS.split(",").map((email) => email.toLowerCase())
+    : [];
+
+  const uniqueGuests = guests.filter(
+    (guest) =>
+      !booking.attendees.some((attendee) => guest === attendee.email) &&

Leaderboard for this case

hard · 1 of 9 bots fully caught it (11% solve rate) · 78% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Cubic solved 5/5 100.0% 11 0
2 cursor partial 4/5 88.9% 6 0
3 Drape (Review) partial 4/5 88.9% 9 0
4 Drape (Deep Review) partial 4/5 77.8% 8 0
5 greptile partial 4/5 77.8% 6 0
6 Mjolnir (Opus 5.5) partial 4/5 77.8% 7 0
7 qodo partial 4/5 77.8% 9 0
8 Claude Code (Opus 5.5) partial 3/5 66.7% 7 0
9 Mjolnir (Sonnet 5.5) partial 3/5 66.7% 7 1

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ off by one
d3 medium ✓ exact
d4 low ✗ —
d5 medium ✗ —
valid · matches d2 · impact medium
valid · impact medium
The handler lets attendees and team admins through the permission check, then builds the EventManager from the caller's credentials instead of the booking organizer's. When a non-organizer adds guests, the calendar update runs against the wrong account. The attendees were already written to the database before this call. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 3/3: valid=3]
valid · matches d1 · impact medium
valid · matches d3 · impact medium
valid · impact medium
Any attendee is authorized. The handler never checks booking status, seats or disableGuests, and puts no limit on the number of guests. Each added address gets an email, so the abuse vector is real. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 3/3: valid=3]
valid · impact low
New guests are stored with an empty name, and the attendee email builds its `to` field from attendee.name. The existing booking flow also creates guests with empty names, so the impact is cosmetic. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 3/4: valid=3, invalid=1]
valid · impact low
The template string is always non-empty, so the unable_to_add_guests fallback can never show. onSuccess never resets isInvalidEmail, so a stale error banner stays visible. [grounded: tree apps/web/components/dialog/AddGuestsDialog.tsx] [consensus 3/3: valid=3]
raw comments (7)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47
`isTeamAdminOrOwner` combines `isTeamAdmin(...) && isTeamOwner(...)`. It should use `||`. `isTeamAdmin` already matches ADMIN or OWNER, so with `&&` the check only passes for team OWNERs. Team ADMINs who don't organize the booking get a FORBIDDEN error.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:160
EventManager is built from the caller's (`ctx.user`) credentials, not the booking organizer's. The handler also lets attendees and team admins/owners call it. When they do, `updateCalendarAttendees` tries to update the organizer's calendar and video references with the wrong user's credentials. The update fails or does nothing, so the external calendar invite never gets the new guests even though the DB and emails say they were added. If that call throws, the request errors after attendees have already been written.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:77
The blacklist is lowercased but guest emails aren't normalized before the check. Submitting `Blocked@Example.com` gets past `BLACKLISTED_GUEST_EMAILS`. The duplicate-attendee check (`guest === attendee.email`) and the `isAttendee` authorization check are also case-sensitive, so the same person can be added twice with different casing.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
`sendAddGuestsEmails` gets the raw `guests` input instead of the filtered `uniqueGuests`. If the input includes an existing attendee's email, that attendee is treated as a new guest and gets a fresh booking-confirmation email instead of the 'guests added' notification.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:52
Any attendee can add an unlimited number of arbitrary email addresses to a booking. The handler doesn't check booking status (cancelled or past), seated events, or `disableGuests`, and has no limit on how many guests can be added. Each added address gets an email sent from the platform under the organizer's name, which can be abused to send spam. On seated events, it can also expose other attendees' details.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:101
New attendees are created with `name: ""`. Templates and calendar invites that render the attendee name show blank entries for them.
apps/web/components/dialog/AddGuestsDialog.tsx:44
The error message is the template string `${err.data?.code}: ...`, which is always non-empty, so the `unable_to_add_guests` fallback can never show. Separately, `isInvalidEmail` is only cleared on Cancel. After a successful add or after the user fixes the input, the stale error banner stays visible.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ exact
d3 medium ✓ exact
d4 low ✓ off by one
d5 medium ✓ exact
valid · impact low
The sibling organizer emails (location-change, scheduled) use EMAIL_FROM_NAME. This new email uses APP_NAME, so a configured sender name is ignored here. [grounded: tree packages/emails/templates/organizer-add-guests-email.ts] [consensus 5/5: valid=5]
valid · impact medium
The parent OrganizerScheduledEmail passes teamMember to renderEmail, and the template uses props.teamMember for translation, locale and timezone. The new class leaves it out, so team-member copies are rendered with the organizer's settings. [grounded: tree packages/emails/templates/organizer-add-guests-email.ts] [consensus 5/5: valid=5]
valid · matches d5 · impact medium
valid · impact low
EmailField/InputField generates its own id with useId, so no input has id "emails" and the label is not linked to any input. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
The tooltip text is hardcoded even though the component already uses t(), so it stays in English for every locale. [grounded: diff] [consensus 5/5: valid=5]
valid · matches d3 · impact medium
valid · matches d4 · impact low
valid · matches d1 · impact medium
valid · matches d2 · impact medium
valid · impact low
onOpenChange only toggles the open flag. The dialog stays mounted in BookingListItem, so when it is closed with Escape or the overlay, the email list and error state survive into the next open. [grounded: diff] [consensus 5/5: valid=5]
valid · impact low
Both the client Set check and the server comparison with existing attendees are case-sensitive, so the same address in different casing gets through and is saved as a separate attendee. [grounded: diff] [consensus 5/5: valid=5]
raw comments (12)
packages/emails/templates/organizer-add-guests-email.ts:23
<!-- cubic:v=8421212c-a23e-4337-86d5-a912b4ababbf --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":10} --> P2: When `EMAIL_FROM_NAME` is configured, this email uses `APP_NAME` instead of the configured sender name. Use `EMAIL_FROM_NAME` so add-guests emails keep the same branding as the other organizer emails. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/emails/templates/organizer-add-guests-email.ts, line 23: <comment>When `EMAIL_FROM_NAME` is configured, this email uses `APP_NAME` instead of the configured sender name. Use `EMAIL_FROM_NAME` so add-guests emails keep the same branding as the other organizer emails.</comment> <file context> @@ -0,0 +1,38 @@ + }), + method: "REQUEST", + }, + from: `${APP_NAME} <${this.getMailerOptions().from}>`, + to: toAddresses.join(","), + replyTo: [this.calEvent.organizer.email, ...this.calEvent.attendees.map(({ email }) => email)], </file context> ``` </details>
packages/emails/templates/organizer-add-guests-email.ts:33
<!-- cubic:v=16429061-c7e8-4700-82aa-d6a2ec501cde --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":9} --> P2: When a team member receives this email, the HTML is rendered with the organizer's language, locale, timezone, and time format because `teamMember` is omitted. Pass `this.teamMember` to render the message for its actual recipient. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/emails/templates/organizer-add-guests-email.ts, line 33: <comment>When a team member receives this email, the HTML is rendered with the organizer's language, locale, timezone, and time format because `teamMember` is omitted. Pass `this.teamMember` to render the message for its actual recipient.</comment> <file context> @@ -0,0 +1,38 @@ + })}`, + html: await renderEmail("OrganizerAddGuestsEmail", { + attendee: this.calEvent.organizer, + calEvent: this.calEvent, + }), + text: this.getTextBody("new_guests_added"), </file context> ``` </details>
packages/emails/email-manager.ts:525
<!-- cubic:v=92ad52a2-2a04-42a3-baed-166278239c12 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":9} --> P2: When an event type disables standard host or attendee emails, `sendAddGuestsEmails` still sends the corresponding guest-update emails because both recipient groups are queued unconditionally. Accept the event type metadata and apply the same host/attendee suppression checks used by the other standard email senders. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/emails/email-manager.ts, line 525: <comment>When an event type disables standard host or attendee emails, `sendAddGuestsEmails` still sends the corresponding guest-update emails because both recipient groups are queued unconditionally. Accept the event type metadata and apply the same host/attendee suppression checks used by the other standard email senders.</comment> <file context> @@ -520,6 +522,32 @@ export const sendLocationChangeEmails = async ( await Promise.all(emailsToSend); }; +export const sendAddGuestsEmails = async (calEvent: CalendarEvent, newGuests: string[]) => { + const calendarEvent = formatCalEvent(calEvent); + </file context> ``` </details>
packages/ui/form/MultiEmail.tsx:21
<!-- cubic:v=c5632b71-4f43-452f-8bea-b484d0bd9ff4 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":10} --> P2: The visible label is not associated with any email input because `EmailField` generates its own ID rather than `emails`. Use a fieldset/legend or provide a shared accessible label and matching IDs for the rendered inputs. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/ui/form/MultiEmail.tsx, line 21: <comment>The visible label is not associated with any email input because `EmailField` generates its own ID rather than `emails`. Use a fieldset/legend or provide a shared accessible label and matching IDs for the rendered inputs.</comment> <file context> @@ -0,0 +1,96 @@ + <> + {value.length ? ( + <div> + <label htmlFor="emails" className="text-default my-2 block text-sm font-medium"> + {label} + </label> </file context> ``` </details>
packages/ui/form/MultiEmail.tsx:46
<!-- cubic:v=c215181d-ab8e-448b-b976-0f5753001e93 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":10} --> P2: The remove tooltip is hardcoded in English, so it remains untranslated for every non-English locale. Add a `remove_email` translation and render it with `t("remove_email")`. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/ui/form/MultiEmail.tsx, line 46: <comment>The remove tooltip is hardcoded in English, so it remains untranslated for every non-English locale. Add a `remove_email` translation and render it with `t("remove_email")`.</comment> <file context> @@ -0,0 +1,96 @@ + }} + addOnSuffix={ + !readOnly ? ( + <Tooltip content="Remove email"> + <button className="m-1" type="button"> + <Icon name="x" width={12} className="text-default" /> </file context> ``` </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
<!-- cubic:v=643318fa-ad73-4bb3-ad1d-96cbe579030b --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":10} --> P2: When a request mixes an existing attendee with a new guest, this passes the original `guests` list and treats the existing attendee as newly scheduled. Pass `uniqueGuests` so only inserted addresses receive scheduled emails. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts, line 168: <comment>When a request mixes an existing attendee with a new guest, this passes the original `guests` list and treats the existing attendee as newly scheduled. Pass `uniqueGuests` so only inserted addresses receive scheduled emails.</comment> <file context> @@ -0,0 +1,174 @@ + await eventManager.updateCalendarAttendees(evt, booking); + + try { + await sendAddGuestsEmails(evt, guests); + } catch (err) { + console.log("Error sending AddGuestsEmails"); </file context> ``` </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74
<!-- cubic:v=827cab41-b5df-4f61-b687-7e85ccad6a88 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":9} --> P2: Direct callers can submit the same email twice, and this filter only compares against existing attendees. Deduplicate `guests` before filtering so `createMany` cannot insert duplicate attendee rows. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts, line 74: <comment>Direct callers can submit the same email twice, and this filter only compares against existing attendees. Deduplicate `guests` before filtering so `createMany` cannot insert duplicate attendee rows.</comment> <file context> @@ -0,0 +1,174 @@ + ? process.env.BLACKLISTED_GUEST_EMAILS.split(",").map((email) => email.toLowerCase()) + : []; + + const uniqueGuests = guests.filter( + (guest) => + !booking.attendees.some((attendee) => guest === attendee.email) && </file context> ``` </details> ```suggestion const uniqueGuests = [...new Set(guests)].filter( ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:77
<!-- cubic:v=d12edbc2-e1ae-4fad-bf02-eca8a57814e0 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":9} --> P2: A blacklisted address can bypass this check by using uppercase letters because the configured entries are lowercased but `guest` is not. Compare against `guest.toLowerCase()` before inserting the attendee. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts, line 77: <comment>A blacklisted address can bypass this check by using uppercase letters because the configured entries are lowercased but `guest` is not. Compare against `guest.toLowerCase()` before inserting the attendee.</comment> <file context> @@ -0,0 +1,174 @@ + const uniqueGuests = guests.filter( + (guest) => + !booking.attendees.some((attendee) => guest === attendee.email) && + !blacklistedGuestEmails.includes(guest) + ); + </file context> ``` </details> ```suggestion !blacklistedGuestEmails.includes(guest.toLowerCase()) ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47
<!-- cubic:v=d83e8fa3-0d3d-4a6e-a3e3-f110b0d251d1 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":10} --> P2: Team admins cannot add guests because `isTeamAdmin` already includes admins and owners, but this `&&` requires admins to also be owners. Use `||` so the declared admin-or-owner permission works. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts, line 47: <comment>Team admins cannot add guests because `isTeamAdmin` already includes admins and owners, but this `&&` requires admins to also be owners. Use `||` so the declared admin-or-owner permission works.</comment> <file context> @@ -0,0 +1,174 @@ + if (!booking) throw new TRPCError({ code: "NOT_FOUND", message: "booking_not_found" }); + + const isTeamAdminOrOwner = + (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && + (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); + </file context> ``` </details> ```suggestion (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) || ```
apps/web/components/dialog/AddGuestsDialog.tsx:61
<!-- cubic:v=b829b8af-6106-4a19-bbd4-ab1ae8342334 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":9} --> P2: When the dialog is dismissed with Escape or the overlay, reopening it shows the previous emails and validation error instead of a fresh form. Reset `multiEmailValue` and `isInvalidEmail` whenever `open` becomes false, not only from Cancel or mutation success. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/components/dialog/AddGuestsDialog.tsx, line 61: <comment>When the dialog is dismissed with Escape or the overlay, reopening it shows the previous emails and validation error instead of a fresh form. Reset `multiEmailValue` and `isInvalidEmail` whenever `open` becomes false, not only from Cancel or mutation success.</comment> <file context> @@ -0,0 +1,107 @@ + }; + + return ( + <Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}> + <DialogContent enableOverflow> + <div className="flex flex-row space-x-3"> </file context> ``` </details>
apps/web/components/dialog/AddGuestsDialog.tsx:27
<!-- cubic:v=f981ed3b-1efa-44ac-9803-910ec4920fb8 --> <!-- cubic:review-run=a9e4b32e-39cd-5148-81fe-722f83730d22 --> <!-- metadata:{"confidence":7} --> P2: When email casing differs, this uniqueness check lets equivalent addresses through, and `addGuestsHandler` can persist them as separate attendees. Normalize email addresses for uniqueness and for existing-attendee comparisons before adding them. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/components/dialog/AddGuestsDialog.tsx, line 27: <comment>When email casing differs, this uniqueness check lets equivalent addresses through, and `addGuestsHandler` can persist them as separate attendees. Normalize email addresses for uniqueness and for existing-attendee comparisons before adding them.</comment> <file context> @@ -0,0 +1,107 @@ +export const AddGuestsDialog = (props: IAddGuestsDialog) => { + const { t } = useLocale(); + const ZAddGuestsInputSchema = z.array(z.string().email()).refine((emails) => { + const uniqueEmails = new Set(emails); + return uniqueEmails.size === emails.length; + }); </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **11 issues found** across 15 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="packages/emails/templates/organizer-add-guests-email.ts"> <violation number="1" location="packages/emails/templates/organizer-add-guests-email.ts:23"> P2: When `EMAIL_FROM_NAME` is configured, this email uses `APP_NAME` instead of the configured sender name. Use `EMAIL_FROM_NAME` so add-guests emails keep the same branding as the other organizer emails.</violation> <violation number="2" location="packages/emails/templates/organizer-add-guests-email.ts:33"> P2: When a team member receives this email, the HTML is rendered with the organizer's language, locale, timezone, and time format because `teamMember` is omitted. Pass `this.teamMember` to render the message for its actual recipient.</violation> </file> <file name="packages/emails/email-manager.ts"> <violation number="1" location="packages/emails/email-manager.ts:525"> P2: When an event type disables standard host or attendee emails, `sendAddGuestsEmails` still sends the corresponding guest-update emails because both recipient groups are queued unconditionally. Accept the event type metadata and apply the same host/attendee suppression checks used by the other standard email senders.</violation> </file> <file name="packages/ui/form/MultiEmail.tsx"> <violation number="1" location="packages/ui/form/MultiEmail.tsx:21"> P2: The visible label is not associated with any email input because `EmailField` generates its own ID rather than `emails`. Use a fieldset/legend or provide a shared accessible label and matching IDs for the rendered inputs.</violation> <violation number="2" location="packages/ui/form/MultiEmail.tsx:46"> P2: The remove tooltip is hardcoded in English, so it remains untranslated for every non-English locale. Add a `remove_email` translation and render it with `t("remove_email")`.</violation> </file> <file name="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts"> <violation number="1" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47"> P2: Team admins cannot add guests because `isTeamAdmin` already includes admins and owners, but this `&&` requires admins to also be owners. Use `||` so the declared admin-or-owner permission works.</violation> <violation number="2" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74"> P2: Direct callers can submit the same email twice, and this filter only compares against existing attendees. Deduplicate `guests` before filtering so `createMany` cannot insert duplicate attendee rows.</violation> <violation number="3" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:77"> P2: A blacklisted address can bypass this check by using uppercase letters because the configured entries are lowercased but `guest` is not. Compare against `guest.toLowerCase()` before inserting the attendee.</violation> <violation number="4" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168"> P2: When a request mixes an existing attendee with a new guest, this passes the original `guests` list and treats the existing attendee as newly scheduled. Pass `uniqueGuests` so only inserted addresses receive scheduled emails.</violation> </file> <file name="apps/web/components/dialog/AddGuestsDialog.tsx"> <violation number="1" location="apps/web/components/dialog/AddGuestsDialog.tsx:27"> P2: When email casing differs, this uniqueness check lets equivalent addresses through, and `addGuestsHandler` can persist them as separate attendees. Normalize email addresses for uniqueness and for existing-attendee comparisons before adding them.</violation> <violation number="2" location="apps/web/components/dialog/AddGuestsDialog.tsx:61"> P2: When the dialog is dismissed with Escape or the overlay, reopening it shows the previous emails and validation error instead of a fresh form. Reset `multiEmailValue` and `isInvalidEmail` whenever `open` becomes false, not only from Cancel or mutation success.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/19/ai_pr_review_github_delivery_20df61380686c98443cc9bc9d1bcb2da72ef860e66b28cd349ed1f894cd49756?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F19)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_20df61380686c98443cc9bc9d1bcb2da72ef860e66b28cd349ed1f894cd49756:1c405f0153c5c5a78ece498c15006296338b66c6:a9e4b32e-39cd-5148-81fe-722f83730d22 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ exact
d3 medium ✓ exact
d4 low ✗ —
d5 medium ✓ off by one
valid · matches d2 · impact medium
valid · matches d3 · impact medium
valid · matches d1 · impact medium
valid · impact medium
The new handler only checks that the booking exists and that the caller has permission. It never checks booking.status, and it sends emails and ICS invites marked CONFIRMED. The UI also shows the edit actions on past pending bookings, and anyone can call the API directly. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 5/5: valid=5]
valid · impact medium
The handler adds attendees with createMany and never checks seatsPerTimeSlot or creates BookingSeat records. On seated events this goes past seat capacity. sendAddGuestsEmails also emails every attendee the full attendee list, even when seatsShowAttendees is off. [grounded: diff-section packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 5/5: valid=5]
valid · matches d5 · impact medium
raw comments (7)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:48
### Team admin permission check uses AND **Medium Severity** <!-- DESCRIPTION START --> `isTeamAdminOrOwner` combines `isTeamAdmin` and `isTeamOwner` with `&&`, so only team owners pass. `isTeamAdmin` already includes owners, so team admins who are not the organizer or an attendee cannot add guests. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 72287dec-3a1f-4cc4-a465-01d4f84616e9 --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts#L45-L48 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmQ3YzI5ZDc0LTI3OWItNDhhMi05ZWJhLTA3MzZhZjA0OGE2OSIsImVuY3J5cHRpb25LZXkiOiJzMmtuOUVFUmJuSTlhUU13c3YyX1MwR0pnanlIU29yTU1LYlM5WU9FWHZVIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmQ3YzI5ZDc0LTI3OWItNDhhMi05ZWJhLTA3MzZhZjA0OGE2OSIsImVuY3J5cHRpb25LZXkiOiJzMmtuOUVFUmJuSTlhUU13c3YyX1MwR0pnanlIU29yTU1LYlM5WU9FWHZVIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
### Existing attendees get confirmation emails **Medium Severity** <!-- DESCRIPTION START --> `sendAddGuestsEmails` is called with the original `guests` list instead of `uniqueGuests`. Existing attendees whose emails are resubmitted are treated as new guests and receive a full `AttendeeScheduledEmail` confirmation rather than the guests-added notice. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 5ca5b4fb-9270-4f21-bac2-b57915ff6f9b --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts#L167-L168 packages/emails/email-manager.ts#L538-L546 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`packages/emails/email-manager.ts#L538-L546`](https://github.com/drape-io/crbench-cursor-2026-09/blob/d504fcc82a150f06c4e62edec2c0227f3cc7ed74/packages/emails/email-manager.ts#L538-L546) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjlhYmYyM2E3LWEwMzItNDRmOS04YzZjLWNkMmIwZDg1YWRjZSIsImVuY3J5cHRpb25LZXkiOiJHLXpOdldjU3c1SGFWaU1tbVY5aC1mZHQtOGdjZ3U5Nk9VazYyODB6SDhrIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjlhYmYyM2E3LWEwMzItNDRmOS04YzZjLWNkMmIwZDg1YWRjZSIsImVuY3J5cHRpb25LZXkiOiJHLXpOdldjU3c1SGFWaU1tbVY5aC1mZHQtOGdjZ3U5Nk9VazYyODB6SDhrIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:78
### Guest blacklist comparison is case-sensitive **Medium Severity** <!-- DESCRIPTION START --> Blacklisted emails are lowercased, but incoming guest addresses are compared as-is and without `extractBaseEmail`. A blocked address can be added by changing case or using a plus-alias, unlike the booking-time blacklist check. Existing-attendee matching is also case-sensitive, so the same person can be inserted twice. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: ab22bd98-5550-46c8-b317-d44f066caff4 --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts#L69-L78 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmUyYTk0YWQ2LWQ2ZDYtNDI3Yi1iNzhmLTI0NmJkNDRjMGNlZCIsImVuY3J5cHRpb25LZXkiOiJreFhYRzdUa3EyLTRJdWlQc1ZrdlItQ1FkUkZNUG1YU3VlX1J3dHFnUmh3IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmUyYTk0YWQ2LWQ2ZDYtNDI3Yi1iNzhmLTI0NmJkNDRjMGNlZCIsImVuY3J5cHRpb25LZXkiOiJreFhYRzdUa3EyLTRJdWlQc1ZrdlItQ1FkUkZNUG1YU3VlX1J3dHFnUmh3IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:56
### Guests can be added to cancelled bookings **Medium Severity** <!-- DESCRIPTION START --> The handler never checks `booking.status`. Guests can be added to cancelled, rejected, or pending bookings, which then sends CONFIRMED calendar invites and guest-added emails for meetings that are not active. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: c7cba68a-f2d2-41b5-995a-da95aa86159b --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts#L43-L56 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmM2NTA2OTYzLTllODUtNDFhYS05OGFhLWQ3NmEyZWJlOWExZCIsImVuY3J5cHRpb25LZXkiOiI1REpSajRvM3FlZV9HclNxTm42dmExRWlUOU84YlJRYktnVHhRS0M2RkZJIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmM2NTA2OTYzLTllODUtNDFhYS05OGFhLWQ3NmEyZWJlOWExZCIsImVuY3J5cHRpb25LZXkiOiI1REpSajRvM3FlZV9HclNxTm42dmExRWlUOU84YlJRYktnVHhRS0M2RkZJIiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:106
### Seated bookings skip seat limits **Medium Severity** <!-- DESCRIPTION START --> Guests are created as plain attendees with no `BookingSeat` and no `seatsPerTimeSlot` check. On seated event types this bypasses capacity, skips per-seat reference UIDs, and can expose hidden attendees when `seatsShowAttendees` is off. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 9f9b8d3f-eedd-47f1-a020-25ce1794bbf7 --> <!-- LOCATIONS START packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts#L91-L106 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjQ0NWYyZjJjLTgzOWItNGIzMy05MTRhLWNlMmI4N2MyNjU0MCIsImVuY3J5cHRpb25LZXkiOiJIVS1ub2VIbUdKS25aVUdZT0tHTlktUlY4Yy11eDF6QjdoWk1NcUlVckI0IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjQ0NWYyZjJjLTgzOWItNGIzMy05MTRhLWNlMmI4N2MyNjU0MCIsImVuY3J5cHRpb25LZXkiOiJIVS1ub2VIbUdKS25aVUdZT0tHTlktUlY4Yy11eDF6QjdoWk1NcUlVckI0IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
packages/emails/email-manager.ts:550
### Guest emails ignore disabled email setting **Low Severity** <!-- DESCRIPTION START --> `sendAddGuestsEmails` always emails the organizer, team members, and attendees. It never consults `eventTypeDisableHostEmail` / `eventTypeDisableAttendeeEmail`, so event types with standard emails disabled still receive guest-added and confirmation mail. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 2e4195e5-8dc9-4148-a0a5-5a3673e9edbc --> <!-- LOCATIONS START packages/emails/email-manager.ts#L524-L550 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRkOTU5Y2UxLTFlM2EtNGM3Zi1iZmRiLTMyMWYzODQzNjkxOSIsImVuY3J5cHRpb25LZXkiOiIyal9EQXdQZGNHLUFjNnUwSmFnaU40bUxoNWR0U05BNGFPSktQZ21RYWl3IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRkOTU5Y2UxLTFlM2EtNGM3Zi1iZmRiLTMyMWYzODQzNjkxOSIsImVuY3J5cHRpb25LZXkiOiIyal9EQXdQZGNHLUFjNnUwSmFnaU40bUxoNWR0U05BNGFPSktQZ21RYWl3IiwiYnJhbmNoIjoidDItY2FsLWNvbS0xNDc0MCIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjE5LCJjb21taXRTaGEiOiJkNTA0ZmNjODJhMTUwZjA2YzRlNjJlZGVjMmMwMjI3ZjNjYzdlZDc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using default effort and found 6 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTowZDYyMmNlMy1jZTY3LTRiNDEtODQ1YS1mOTlhN2ViZDczNTgiLCJlbmNyeXB0aW9uS2V5IjoiUUN6T3RjT095Qmg4RElsM1VEcllMamQ5NkRCcm1QN3NIZHBiWWpsdERGYyIsImJyYW5jaCI6InQyLWNhbC1jb20tMTQ3NDAiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d504fcc82a150f06c4e62edec2c0227f3cc7ed74. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ exact
d3 medium ✓ off by one
d4 low ✓ exact
d5 medium ✗ —
valid · matches d2 · impact medium
valid · impact low
The new handler compares emails with strict equality and does not normalize case. An existing attendee typed with different capitalization passes the filter and is inserted again. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d4 · impact low
valid · impact low
The template literal always contains ': ', so it is never empty and the || fallback can never run. When err.data is missing the toast starts with 'undefined: '. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · impact low
Only the Cancel button resets isInvalidEmail. onSuccess and onOpenChange do not reset it, and the dialog stays mounted in BookingListItem, so a stale error still shows the next time the dialog opens. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact medium
valid · impact medium
The handler builds EventManager from the caller's credentials. In updateAllCalendarEvents, a reference with no credentialId is updated only with this.calendarCredentials of the same type. When an attendee or admin is the caller, those are the caller's credentials, so the organizer's calendar event is not updated. [grounded: diff] [consensus 3/3: valid=3]
raw comments (8)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47
**Team admins can't add guests to team bookings** `isTeamAdminOrOwner` joins the two checks with `&&`, but `isTeamAdmin` already matches ADMIN or OWNER, so only owners pass. Admins who aren't the organizer get FORBIDDEN. Use `||`, or just `isTeamAdmin` on its own. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46 const isTeamAdminOrOwner = packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47 (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:48 (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); packages/lib/server/queries/teams/index.ts:264 export async function isTeamAdmin(userId: number, teamId: number) { packages/lib/server/queries/teams/index.ts:265 const team = await prisma.membership.findFirst({ packages/lib/server/queries/teams/index.ts:266 where: { packages/lib/server/queries/teams/index.ts:267 userId, packages/lib/server/queries/teams/index.ts:268 teamId, packages/lib/server/queries/teams/index.ts:269 accepted: true, packages/lib/server/queries/teams/index.ts:270 OR: [{ role: "ADMIN" }, { role: "OWNER" }], ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:76
**Existing attendee re-added when email casing differs** The check for existing attendees compares emails exactly. Typing an existing attendee's address with different capitals adds them again as a new guest. Compare lowercased emails. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74 const uniqueGuests = guests.filter( packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:75 (guest) => packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:76 !booking.attendees.some((attendee) => guest === attendee.email) && packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:77 !blacklistedGuestEmails.includes(guest) ```
packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:5
**API allows the same guest twice** Only the dialog checks that emails are unique; the server schema and the `uniqueGuests` filter do not. A direct API call with repeated emails creates duplicate attendee rows, and each copy is emailed. Dedupe `guests` on the server, e.g. a `.refine` uniqueness check or a `Set` in the handler. ``` packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:3 export const ZAddGuestsInputSchema = z.object({ packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:4 bookingId: z.number(), packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:5 guests: z.array(z.string().email()), packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:6 }); packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:92 const bookingAttendees = await prisma.booking.update({ packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:93 where: { packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:94 id: bookingId, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:95 }, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:96 include: { packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:97 attendees: true, ```
apps/web/components/dialog/AddGuestsDialog.tsx:44
**'Unable to add guests' fallback never shown** The template string is never empty, so the `||` fallback never runs. When `err.data` is missing the toast reads 'undefined: …'. Build the message only when `err.data?.code` exists, and fall back otherwise. ``` apps/web/components/dialog/AddGuestsDialog.tsx:43 const message = `${err.data?.code}: ${t(err.message)}`; apps/web/components/dialog/AddGuestsDialog.tsx:44 showToast(message || t("unable_to_add_guests"), "error"); ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
**Existing attendees sent a fresh booking confirmation** `sendAddGuestsEmails` gets the raw `guests` list instead of `uniqueGuests`. If the request includes someone already on the booking, they get the full 'scheduled' email instead of the 'guests added' notice. Pass `uniqueGuests`. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168 await sendAddGuestsEmails(evt, guests); packages/emails/email-manager.ts:541 if (newGuests.includes(attendee.email)) { packages/emails/email-manager.ts:542 return sendEmail(() => new AttendeeScheduledEmail(calendarEvent, attendee)); packages/emails/email-manager.ts:543 } else { ```
apps/web/components/dialog/AddGuestsDialog.tsx:54
**Invalid-email warning stays after a valid submit** `isInvalidEmail` goes back to false only when Cancel is clicked. After a failed attempt, a corrected successful submit, or closing the dialog by clicking outside, still leaves the error showing the next time the dialog opens. Reset `isInvalidEmail` on a successful submit and whenever the dialog closes. ``` apps/web/components/dialog/AddGuestsDialog.tsx:36 onSuccess: async () => { apps/web/components/dialog/AddGuestsDialog.tsx:37 showToast(t("guests_added"), "success"); apps/web/components/dialog/AddGuestsDialog.tsx:38 setIsOpenDialog(false); apps/web/components/dialog/AddGuestsDialog.tsx:39 setMultiEmailValue([""]); apps/web/components/dialog/AddGuestsDialog.tsx:77 <div className="my-4 flex text-sm text-red-700"> apps/web/components/dialog/AddGuestsDialog.tsx:78 <div className="flex-shrink-0"> apps/web/components/dialog/AddGuestsDialog.tsx:79 <Icon name="triangle-alert" className="h-5 w-5" /> apps/web/components/dialog/AddGuestsDialog.tsx:80 </div> apps/web/components/dialog/AddGuestsDialog.tsx:81 <div className="ml-3"> apps/web/components/dialog/AddGuestsDialog.tsx:82 <p className="font-medium">{t("emails_must_be_unique_valid")}</p> ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74
**Blocked guest emails get through with different case** Only the blocklist is lowercased. The guest email isn't lowercased or reduced to its base address the way `handleNewBooking` does it, so `Bad@x.com` or `bad+1@x.com` gets past `blacklistedGuestEmails`. Compare `extractBaseEmail(guest).toLowerCase()` against the lowercased blocklist. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:70 const blacklistedGuestEmails = process.env.BLACKLISTED_GUEST_EMAILS packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:71 ? process.env.BLACKLISTED_GUEST_EMAILS.split(",").map((email) => email.toLowerCase()) packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:72 : []; packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74 const uniqueGuests = guests.filter( packages/features/bookings/lib/handleNewBooking.ts:736 const blacklistedGuestEmails = process.env.BLACKLISTED_GUEST_EMAILS packages/features/bookings/lib/handleNewBooking.ts:737 ? process.env.BLACKLISTED_GUEST_EMAILS.split(",") packages/features/bookings/lib/handleNewBooking.ts:738 : []; packages/features/bookings/lib/handleNewBooking.ts:740 const guestsRemoved: string[] = []; packages/features/bookings/lib/handleNewBooking.ts:741 const guests = (reqGuests || []).reduce((guestArray, guest) => { packages/features/bookings/lib/handleNewBooking.ts:742 const baseGuestEmail = extractBaseEmail(guest).toLowerCase(); ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:159
**Organizer's calendar misses guests on legacy references** When an attendee or team admin adds guests, EventManager is built from the caller's credentials. Calendar references with no credentialId are then updated only through the caller's same-type credentials, so the organizer's event isn't updated. Build EventManager from the organizer's credentials (booking.user). ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:160 const eventManager = new EventManager({ packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:161 ...user, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:162 credentials: [...credentials], packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:163 }); packages/core/EventManager.ts:596 public async updateCalendarAttendees(event: CalendarEvent, booking: PartialBooking) { packages/core/EventManager.ts:597 if (booking.references.length === 0) { packages/core/EventManager.ts:598 console.error("Tried to update references but there wasn't any."); packages/core/EventManager.ts:599 return; packages/core/EventManager.ts:600 } packages/core/EventManager.ts:601 await this.updateAllCalendarEvents(event, booking); ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ exact
d3 medium ✓ off by one
d4 low ✗ —
d5 medium ✓ exact
valid · matches d2 · impact medium
valid · matches d1 · impact medium
valid · matches d3 · impact medium
valid · impact low
The template literal always yields a non-empty string, so `|| t("unable_to_add_guests")` never runs, and a missing code shows up as 'undefined: ...'. [grounded: tree apps/web/components/dialog/AddGuestsDialog.tsx] [consensus 3/3: valid=3]
valid · impact low
setIsInvalidEmail(false) is called only in the Cancel handler. onSuccess, onOpenChange and value edits never clear it, so the error message stays visible. [grounded: tree apps/web/components/dialog/AddGuestsDialog.tsx] [consensus 3/3: valid=3]
valid · impact medium
EventManager.updateAllCalendarEvents matches references with no credentialId, and other_calendar integrations, only against this.calendarCredentials, which here are the caller's. So when an attendee or admin adds guests, the host's events are not updated. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 3/3: valid=3]
valid · matches d5 · impact medium
valid · impact medium
The new handler lets any logged-in attendee add arbitrary guests. That changes the organizer's calendar event and sends emails in the organizer's name, which is broader than bookingsProcedure, the check editLocation uses. [grounded: diff] [consensus 3/4: valid=3, invalid=1]
valid · impact low
The new schema puts no limit on the guests array, and every new guest is sent an email, so an authorized caller can trigger a large number of emails. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts] [consensus 3/3: valid=3]
raw comments (9)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:42
**Team admins wrongly denied; check requires owner** `isTeamAdminOrOwner` ANDs `isTeamAdmin` with `isTeamOwner`. `isTeamAdmin` already accepts OWNER, so the result is true only for owners and team admins are rejected. Use `||`, or only `isTeamAdmin`. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:42 }); packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:44 if (!booking) throw new TRPCError({ code: "NOT_FOUND", message: "booking_not_found" }); packages/lib/server/queries/teams/index.ts:264 export async function isTeamAdmin(userId: number, teamId: number) { packages/lib/server/queries/teams/index.ts:265 const team = await prisma.membership.findFirst({ packages/lib/server/queries/teams/index.ts:266 where: { packages/lib/server/queries/teams/index.ts:267 userId, packages/lib/server/queries/teams/index.ts:268 teamId, packages/lib/server/queries/teams/index.ts:269 accepted: true, packages/lib/server/queries/teams/index.ts:270 OR: [{ role: "ADMIN" }, { role: "OWNER" }], packages/lib/server/queries/teams/index.ts:271 }, ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:58
**Blacklist and duplicate checks are case-sensitive** Blacklisted emails are lowercased but the guest is compared as typed, and the existing-attendee check is also an exact match. Mixed-case input bypasses the blacklist and adds duplicate attendees. Lowercase the guest before comparing against the blacklist and the existing attendees. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:62 select: { packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:63 name: true, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:64 email: true, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:65 timeZone: true, ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:170
**Wrong guest list passed to email sender** `sendAddGuestsEmails` gets the raw `guests` input, not the filtered `uniqueGuests`. Existing attendees included in the input get the new-booking email instead of the guests-added update. Pass uniqueGuests. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:170 console.log("Error sending AddGuestsEmails"); ```
apps/web/components/dialog/AddGuestsDialog.tsx:36
**Error toast fallback never used** The error message is built as a template string that is always non-empty, so the `unable_to_add_guests` fallback is dead. It also shows `undefined: ...` if the error has no code. Use t(err.message) when set, otherwise t("unable_to_add_guests"). ``` apps/web/components/dialog/AddGuestsDialog.tsx:35 const addGuestsMutation = trpc.viewer.bookings.addGuests.useMutation({ apps/web/components/dialog/AddGuestsDialog.tsx:36 onSuccess: async () => { apps/web/components/dialog/AddGuestsDialog.tsx:37 showToast(t("guests_added"), "success"); apps/web/components/dialog/AddGuestsDialog.tsx:38 setIsOpenDialog(false); ```
apps/web/components/dialog/AddGuestsDialog.tsx:45
**Stale invalid-email error persists** `isInvalidEmail` is cleared only by the Cancel button. It stays set after the input is corrected, after a successful add, and when the dialog closes via Esc or overlay. Reset it in onSuccess, in onOpenChange, and when the value changes. ``` apps/web/components/dialog/AddGuestsDialog.tsx:29 }); apps/web/components/dialog/AddGuestsDialog.tsx:30 const { isOpenDialog, setIsOpenDialog, bookingId } = props; apps/web/components/dialog/AddGuestsDialog.tsx:31 const utils = trpc.useUtils(); ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:160
**Older calendar events miss guests when non-host adds** When an attendee or team admin adds guests, EventManager is built from the caller's credentials. Calendar references with no credentialId, and other_calendar integrations, are matched only against those credentials, so the host's event is not updated. Build EventManager from booking.user's credentials. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:160 const eventManager = new EventManager({ packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:161 ...user, packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:162 credentials: [...credentials], packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:163 }); ```
packages/emails/email-manager.ts:525
**Add-guests emails ignore disabled-email settings** `sendAddGuestsEmails` always emails organizer, team and attendees. The sibling `sendLocationChangeEmails` skips them when `eventTypeDisableHostEmail`/`eventTypeDisableAttendeeEmail` are set, and it receives the event type metadata. The new function takes no metadata and the handler passes none. Accept eventTypeMetadata and apply the same two disable checks as sendLocationChangeEmails. ``` packages/emails/email-manager.ts:525 export const sendAddGuestsEmails = async (calEvent: CalendarEvent, newGuests: string[]) => { packages/emails/email-manager.ts:526 const calendarEvent = formatCalEvent(calEvent); packages/emails/email-manager.ts:528 const emailsToSend: Promise<unknown>[] = []; packages/emails/email-manager.ts:529 emailsToSend.push(sendEmail(() => new OrganizerAddGuestsEmail({ calEvent: calendarEvent }))); packages/emails/email-manager.ts:495 export const sendLocationChangeEmails = async ( packages/emails/email-manager.ts:496 calEvent: CalendarEvent, packages/emails/email-manager.ts:497 eventTypeMetadata?: EventTypeMetadata packages/emails/email-manager.ts:498 ) => { packages/emails/email-manager.ts:499 const calendarEvent = formatCalEvent(calEvent); packages/emails/email-manager.ts:501 const emailsToSend: Promise<unknown>[] = []; ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46
**Any attendee can add guests to a booking** Unlike `editLocation` (via `bookingsProcedure`: organizer or collective host only), this handler also lets any attendee matched by email add arbitrary guests. The organizer's calendar event is changed and invitation emails go out in the organizer's name. Drop the isAttendee allowance, or confirm it is intended. ``` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46 const isTeamAdminOrOwner = packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47 (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:48 (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:50 const isOrganizer = booking.userId === user.id; packages/trpc/server/routers/viewer/bookings/util.ts:25 const booking = await prisma.booking.findFirst({ packages/trpc/server/routers/viewer/bookings/util.ts:26 where: { packages/trpc/server/routers/viewer/bookings/util.ts:27 id: bookingId, packages/trpc/server/routers/viewer/bookings/util.ts:28 AND: [ packages/trpc/server/routers/viewer/bookings/util.ts:29 { packages/trpc/server/routers/viewer/bookings/util.ts:30 OR: [ ```
packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:5
**No limit on number of guests** The `guests` array has no max size, so any attendee can add unlimited addresses, each of which gets an invite email. Add .max(N) and .min(1) to the guests array. ``` packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:3 export const ZAddGuestsInputSchema = z.object({ packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:4 bookingId: z.number(), packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:5 guests: z.array(z.string().email()), packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts:6 }); ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ off by one
d3 medium ✓ exact
d4 low ✓ wrong severity
d5 medium ✗ —
valid · matches d2 · impact medium
valid · matches d1 · impact medium
valid · matches d4 · impact low
valid · impact medium
The new handler builds `evt` without a `team` field. `sendAddGuestsEmails` only emails team members through `calendarEvent.team?.members`, so on team bookings only the primary organizer and the attendees get the email. The other team hosts are never notified. [grounded: diff] [consensus 5/5: valid=5]
valid · matches d3 · impact medium
valid · impact medium
The new addGuests handler only checks who the caller is. It never checks `booking.status`, so anyone allowed to call it can add attendees and push calendar updates to a cancelled or rejected booking by calling the API directly. [grounded: diff] [consensus 5/5: valid=5]
raw comments (7)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:48
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Team admins are rejected** `isTeamAdmin` accepts both ADMIN and OWNER roles, but combining it with `isTeamOwner` using `&&` means only owners pass. A team administrator who is neither the booking organizer nor an attendee therefore receives `FORBIDDEN` instead of being allowed to add guests. ```suggestion const isTeamAdminOrOwner = (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) || (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:78
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> <a href="#"><img alt="security" src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2" align="top"></a> **Guest blacklist is bypassable** The configured blacklist entries are lowercased, but submitted addresses are compared without equivalent normalization. A permitted caller can submit `Blocked@Example.com` or `blocked+tag@example.com` for a configured `blocked@example.com`; the address survives the filter, is stored as an attendee, and receives the event invitation and details. The existing booking flow avoids this by applying `extractBaseEmail(...).toLowerCase()` before comparison. **How this was verified:** The attacker-controlled guest address reaches attendee creation and invitation delivery after a case-sensitive comparison against normalized blacklist entries.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:78
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Duplicate attendees are persisted** Duplicate validation exists only in the dialog and is not enforced by the server schema. A direct mutation containing repeated addresses, or case variants of an existing attendee, passes validation and this filter. Because the attendee model has no matching uniqueness constraint, `createMany` stores duplicate rows that then enter calendar updates and email processing.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:147
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Team hosts miss notifications** The constructed `CalendarEvent` does not include `team`, while `sendAddGuestsEmails` only notifies additional team hosts through `calendarEvent.team.members`. For a team booking, only the primary organizer and attendees are notified, so the other team members silently miss the guest-change notification.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> **Existing attendees are misclassified** Email classification receives the original request instead of the filtered list that was actually inserted. If the request contains one existing attendee and one new address, the mutation succeeds for the new address, but the existing attendee is still treated as new and receives a normal scheduled-event email rather than the intended “guests added” update. ```suggestion try { await sendAddGuestsEmails(evt, uniqueGuests); ```
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:56
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Inactive bookings remain mutable** The mutation checks the caller's identity but never checks the booking status, even though the UI hides this action for cancelled and rejected bookings. An attendee or organizer can call the authenticated procedure directly with such a booking ID, causing new attendee records to be created and the external calendar to be updated for a booking that is no longer active.
PR-level
<h3>Greptile Summary</h3> This PR introduces an “Add Guests” booking action, its authenticated mutation, calendar synchronization, and organizer/attendee email notifications, plus a reusable multi-email input. - Adds guest collection and validation in the booking UI. - Persists added attendees and updates connected calendar events. - Introduces dedicated add-guests email templates and translations. - The implementation currently has authorization, blacklist normalization, duplicate persistence, lifecycle, and notification-routing defects. <h3>Confidence Score: 0/5</h3> This PR is not safe to merge until guest authorization, blacklist enforcement, duplicate handling, booking lifecycle validation, and team notification delivery are corrected. Team administrators are incorrectly denied, blacklist variants can become invitees, duplicate attendees can be persisted, inactive bookings remain mutable through the API, and team hosts are omitted from notifications. **Files Needing Attention:** packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts, packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts, packages/emails/email-manager.ts <details open><summary><h3>Security Review</h3></summary> The new guest filter compares normalized blacklist entries against unnormalized request input. Case and subaddress variants can therefore bypass the blacklist and receive booking details. </details> <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts | Implements authorization, filtering, persistence, calendar synchronization, and notification dispatch, but contains the principal correctness and security defects. | | packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts | Defines the mutation input but leaves duplicate and size constraints unenforced on the server. | | packages/emails/email-manager.ts | Adds recipient-specific notifications whose classification depends on receiving the actual filtered set of new guests. | | apps/web/components/dialog/AddGuestsDialog.tsx | Adds the guest-entry dialog and client-side uniqueness validation, although that validation is not mirrored server-side. | | packages/ui/form/MultiEmail.tsx | Adds the reusable dynamic email-list input used by the dialog. | </details> <details open><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A[Booking action or direct tRPC call] --> B[addGuests schema] B --> C[Load booking and authorize caller] C --> D[Filter existing and blacklisted addresses] D --> E[Persist attendee records] E --> F[Build CalendarEvent] F --> G[Update external calendar attendees] G --> H[Send organizer notifications] G --> I[Send existing-attendee update emails] G --> J[Send new-attendee scheduling emails] ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update apps/web/components/booking/Booki..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/40415fdb25104cec4fb636956c442f1b4f98a09d) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284251)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ exact
d2 medium ✓ exact
d3 medium ✓ off by one
d4 low ✓ exact
d5 medium ✗ —
valid · matches d2 · impact medium
valid · impact medium
The blacklist entries are lowercased but the guest emails are compared as submitted, and the existing-attendee check is an exact string match. A mixed-case email therefore gets past both checks in this new handler. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · matches d4 · impact low
valid · impact medium
isTeamAdmin already matches both ADMIN and OWNER memberships, so combining it with isTeamOwner using && limits this check to OWNERs only. Team ADMINs who are not the organizer or an attendee get FORBIDDEN. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact medium
valid · impact low
The raw guests list is passed to sendAddGuestsEmails, so an existing attendee who appears in it is treated as new. That attendee gets the AttendeeScheduledEmail confirmation instead of the guests-added update. [grounded: diff] [consensus 3/3: valid=3]
raw comments (7)
PR-level
[P2] Team admin/owner check uses `&&`, so team admins are locked out packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46-48 `isTeamAdmin` already returns true for both `ADMIN` and `OWNER` memberships. Combining it with `isTeamOwner` using `&&` means the check only passes for team owners. A team ADMIN who is not the organizer or an attendee of the booking gets `FORBIDDEN`, even though the variable name `isTeamAdminOrOwner` says admins should be allowed. This was most likely meant to be `||`, or simply `isTeamAdmin` on its own.
PR-level
[P2] Blacklist and existing-attendee checks are case-sensitive, so they can be bypassed packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:70-78 `BLACKLISTED_GUEST_EMAILS` is lowercased, but each `guest` is compared as submitted, and the check against existing attendees is also an exact string match. If someone submits `Blocked@Example.com` while `blocked@example.com` is blacklisted, the guest is added anyway. Likewise, re-adding an existing attendee with different capitalization creates a duplicate attendee row and sends that person another invite. Both sides should be normalized (for example, lowercased) before comparing.
PR-level
[P3] Emails are sent using the raw `guests` list instead of the filtered `uniqueGuests` packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168 `sendAddGuestsEmails` uses `newGuests` to decide which attendees get the full "scheduled" invite and which get the "guests added" update. Because the handler passes the unfiltered input, a request containing an email that is already an attendee (alongside a new one) makes that existing attendee receive a fresh booking-confirmation email instead of the update notice. Passing `uniqueGuests` would keep the email routing consistent with what was actually inserted.
PR-level
[P3] Duplicate emails in a single request are not deduplicated on the server packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74-78 Uniqueness is only enforced in the client dialog's zod refine. `ZAddGuestsInputSchema` on the server accepts any array, and `uniqueGuests` only filters against existing attendees, not against other entries in the same request. A direct API call such as `guests: ["a@x.com", "a@x.com"]` therefore inserts two attendee rows for the same email and sends that address duplicate invites.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:46
[P2] Team admins can't add guests because the check uses `&&` instead of `||` `isTeamAdmin` already matches both ADMIN and OWNER memberships. Combining it with `isTeamOwner` using `&&` means `isTeamAdminOrOwner` is true only for team OWNERs. A team member with the ADMIN role who is not the organizer or an attendee gets FORBIDDEN, even though the variable name and intent say admins should be allowed.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:74
[P2] The guest blacklist check is case-sensitive, so a mixed-case email gets past it The entries in `BLACKLISTED_GUEST_EMAILS` are lowercased, but each submitted `guest` is compared as typed with `blacklistedGuestEmails.includes(guest)`. Submitting `Blocked@Example.com` when `blocked@example.com` is blacklisted gets past the filter: the address is saved as an attendee and sent emails and calendar invites. `handleNewBooking` lowercases the guest email before comparing, so this endpoint is a way around a protection that already exists in the codebase. The duplicate-attendee check on line 76 is also case-sensitive, so an existing attendee can be added again with different casing.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
[P3] Emails use the unfiltered `guests` list instead of `uniqueGuests` `sendAddGuestsEmails` decides who counts as new from the `newGuests` list it receives: those attendees get a full "scheduled" confirmation, and everyone else gets the "guests added" update. Passing the raw `guests` input means a submitted email that was already an attendee (and was filtered out of `uniqueGuests`) is treated as new. That attendee gets a new-booking confirmation instead of the update email.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
d3 medium ✓ exact
d4 low ✗ —
d5 medium ✗ —
valid · matches d2 · impact medium
valid · matches d3 · impact medium
valid · matches d1 · impact medium
valid · impact medium
isTeamAdmin matches ADMIN or OWNER, and isTeamOwner matches only OWNER (packages/lib/server/queries/teams/index.ts). Combining them with && therefore lets only owners through, so a team ADMIN who is neither the organizer nor an attendee gets FORBIDDEN. [grounded: diff] [consensus 3/3: valid=3]
invalid
When a reference's credentialId is not among the caller's credentials, EventManager.updateAllCalendarEvents loads that credential from the DB by reference.credentialId. So the organizer's calendar is still updated even when an attendee or admin makes the call. [invalid: contradiction] [consensus 3/4: invalid=3, valid=1]
valid · impact low
The handler passes the raw guests list, not uniqueGuests. An address that is already an attendee but appears in the request satisfies newGuests.includes, so that person gets AttendeeScheduledEmail instead of AttendeeAddGuestsEmail. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The catch block drops err and logs only a fixed string, so the cause of an email failure is lost. [grounded: diff] [consensus 3/3: valid=3]
raw comments (7)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47
[P2] Team admin check requires owner as well `isTeamAdminOrOwner` combines `isTeamAdmin` and `isTeamOwner` with `&&`. `isTeamAdmin` already accepts ADMIN or OWNER, so the combined check is true only for owners. Team admins who are not the organizer or an attendee get FORBIDDEN on team bookings, which contradicts the variable name and the apparent intent. It should be `||`, or just `isTeamAdmin`.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:169
[P2] Raw `guests` input is passed to the email sender instead of the deduplicated list The handler computes `uniqueGuests` by dropping existing attendees and blacklisted addresses, but it calls `sendAddGuestsEmails(evt, guests)` with the unfiltered input. In `sendAddGuestsEmails`, any attendee whose email is in `newGuests` gets a full "booking scheduled" email. If the request contains an existing attendee's address alongside a genuinely new one, that existing attendee gets the scheduled email instead of the "guests added" notice. This is only reachable when the caller includes an existing attendee in the list. Passing `uniqueGuests` fixes it.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:77
[P3] Blacklist comparison is case-sensitive on the guest side The blacklist entries are lowercased, but `guest` is compared as submitted. A blacklisted address entered with different casing, such as `Blocked@Example.com`, passes the filter and is added as an attendee. The same applies to the existing-attendee comparison `guest === attendee.email`, so a case variant of an existing attendee's email is treated as new. Only deployments that set `BLACKLISTED_GUEST_EMAILS` are affected. Lowercasing `guest` before both comparisons fixes it.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:47
[P2] Team admin check requires owner as well `isTeamAdmin(...) && isTeamOwner(...)` is true only for team owners. `isTeamAdmin` already accepts ADMIN and OWNER roles, and `isTeamOwner` matches only OWNER, so the conjunction rejects team admins. For a team event booking where the caller is a team ADMIN but not the organizer or an attendee, the handler throws FORBIDDEN, even though the UI shows the action to them. This looks like it should be `||` or just `isTeamAdmin`.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:158
[P2] Calendar update uses the caller's credentials, not the organizer's `EventManager` is built from `getUsersCredentials(ctx.user)` and `...user`, where `ctx.user` is whoever is calling. The handler allows attendees and team admins, not just the organizer. In those cases the calendar references on the booking belong to the organizer's credentials, so `updateCalendarAttendees` has no matching credential. The external calendar event is then silently not updated, yet the DB attendees are already created and the handler reports success. The organizer's credentials, from `booking.user.credentials`, which is already fetched, should be used.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:169
[P2] Emails are sent with the unfiltered `guests` list `sendAddGuestsEmails(evt, guests)` receives the raw input rather than `uniqueGuests`. `sendAddGuestsEmails` uses `newGuests.includes(attendee.email)` to choose between the "scheduled" email and the "guests added" email. If the request mixes new guests with an address that is already an attendee (the filter only drops it from the DB insert), that existing attendee gets a fresh "booking scheduled" email instead of the "guests added" notice. Pass `uniqueGuests`. The blacklist comparison also lowercases the env list but not the guest, so mixed-case blacklisted addresses get through.
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
[P3] Email send failure is swallowed with no useful logging The `catch` logs only a fixed string and drops `err`, so email failures can't be diagnosed.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ off by one
d3 medium ✓ exact
d4 low ✓ wrong severity
d5 medium ✗ —
valid · impact medium
The handler lets attendees and team admins call it, but it builds EventManager from the caller's credentials instead of the organizer's. When a non-organizer adds guests, the organizer's calendar event may not be updated, even though the attendee rows were already saved. [grounded: tree packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts] [consensus 3/3: valid=3]
valid · impact low
The call returns nothing and quietly returns when there are no references. The handler then sends emails and returns 'Guests added' whether or not the calendar sync worked, so the database and the external calendar can get out of sync. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact medium
valid · impact low
The parent OrganizerScheduledEmail passes teamMember to renderEmail, and the template reads props.teamMember for translation and time zone. The new subclass leaves teamMember out, so team-member copies are rendered in the organizer's locale and time zone. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
The catch block throws away err and logs only a fixed string, so the error message and stack trace are lost. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact medium
valid · matches d4 · impact low
valid · matches d1 · impact medium
valid · impact low
The inherited getFormattedDate uses getTimezone/getLocale, which come from calEvent.attendees[0]. So every recipient's subject shows the date in the first attendee's time zone. The parent class doesn't put this date in its subject, so the new code introduces the problem. [grounded: diff] [consensus 3/3: valid=3]
raw comments (11)
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:163
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Calendar updates use the wrong account <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>addGuestsHandler</i></b> persists attendees, then constructs <b><i>EventManager</i></b> with <b><i>ctx.user</i></b> and the caller&#x27;s credentials instead of the booking organizer&#x27;s credential context, while also ignoring the calendar update result. When an authorized attendee or team user updates a calendar reference without <b><i>credentialId</i></b> or without a matching caller credential, the organizer&#x27;s external calendar can be skipped or accessed through the caller&#x27;s same-type account after the database rows have already been committed. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Calendar synchronization uses the authenticated caller's credentials rather than the booking organizer's credentials and does not verify the update result, allowing permitted non-organizer callers to persist guests without reliably updating the organizer's external calendar. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106] - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165] ## Recommended Fix Load the booking organizer's full calendar credential context and construct `EventManager` with the organizer's identity, retaining the authenticated caller only for authorization and audit purposes. Ensure calendar update failures fail the mutation before attendee rows are committed, or compensate for any already-persisted rows when the external update fails. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 2\. Failed calendar sync still reports success <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> <b><i>addGuestsHandler</i></b> commits attendee rows, initializes <b><i>EventManager</i></b> with <b><i>ctx.user</i></b> credentials rather than the booking organizer’s, and ignores the result of <b><i>updateCalendarAttendees</i></b>, which silently returns for missing references and converts update exceptions into unsuccessful results. When a permitted attendee or team user lacks matching calendar credentials, the external event can remain unchanged while the handler continues to send guest notifications and return success. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The mutation uses the caller’s calendar credentials and reports success after persisting attendees without verifying external calendar synchronization, allowing permitted non-organizer callers to add guests without updating the organizer’s calendar. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106] - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165] - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[165-173] - packages/core/EventManager.ts[596-602] ## Recommended Fix Load the booking organizer’s calendar credentials for the update and return and inspect synchronization results from `updateCalendarAttendees`. Require the necessary calendar updates to succeed before committing attendee rows and sending notifications, or compensate already-persisted rows and durably retry or surface synchronization failures so the database and external calendar cannot silently diverge. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:168
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 6\. Existing guests get booking confirmations <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>addGuestsHandler</i></b> filters existing attendees out of <b><i>uniqueGuests</i></b> but passes the original <b><i>guests</i></b> input to <b><i>sendAddGuestsEmails</i></b>. When a request contains both an existing address and a new address, the existing attendee is classified as newly added and receives a fresh scheduled-booking email instead of the guest-change notification. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Notification classification uses the unfiltered request rather than the addresses actually inserted into the booking. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[74-78] - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-168] - packages/emails/email-manager.ts[539-547] ## Recommended Fix Pass the normalized `uniqueGuests` collection to `sendAddGuestsEmails` so only attendees inserted by this mutation receive scheduled-booking notifications. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/emails/templates/organizer-add-guests-email.ts:34
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 7\. Team emails use the organizer's locale <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>OrganizerAddGuestsEmail</i></b> receives a <b><i>teamMember</i></b> recipient but omits that value from the props passed to the React email template. Team-member notifications consequently render their body with the organizer&#x27;s locale and time zone, and the inherited class also builds the subject, text, and calendar attachment from the organizer&#x27;s translation function. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Team-member add-guests emails are rendered and formatted using the organizer's locale rather than the recipient's locale and time zone. ## Fix Focus Areas - packages/emails/templates/organizer-add-guests-email.ts[7-35] - packages/emails/src/templates/OrganizerScheduledEmail.tsx[31-45] ## Recommended Fix Forward `this.teamMember` into the React template and initialize recipient-sensitive translation, time-zone formatting, text, subject, and calendar content from the team member when one is present. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:171
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 8\. Email failures lose their traceback <code>🐞 Bug</code> <code>◔ Observability</code> <pre> The notification catch block discards <b><i>err</i></b> and writes only a fixed string through <b><i>console.log</i></b>. Any rendering, transport, or recipient failure therefore leaves no exception message or traceback with which operators can diagnose the unsuccessful delivery. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Add-guests notification failures are swallowed with a static console message that omits the exception and booking context. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-171] ## Recommended Fix Use the repository's structured logger to record the caught exception with its traceback plus booking and recipient context, while preserving the intended best-effort notification behavior. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:48
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 3\. Team admins cannot add guests <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>isTeamAdminOrOwner</i></b> combines <b><i>isTeamAdmin(user.id, teamId)</i></b> and <b><i>isTeamOwner(user.id, teamId)</i></b> with <b><i>&amp;&amp;</i></b>, so the owner-only predicate negates the admin access already covered by the former. A non-owner team admin who is neither the booking organizer nor an attendee can see team bookings and the new action, but submitting the dialog reaches the <b><i>FORBIDDEN</i></b> branch. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The add-guests team-role check requires a user to be both an admin and an owner, rejecting valid non-owner team administrators. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[46-55] ## Recommended Fix Authorize the operation when either `isTeamAdmin` or `isTeamOwner` succeeds, following the repository's existing team-management authorization pattern. Preserve the organizer and attendee authorization paths. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:78
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 4\. Guests receive duplicate invitations <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>uniqueGuests</i></b> compares unnormalized input against a lowercased blacklist and existing attendees case-sensitively, while checking only attendees loaded before the mutation rather than deduplicating the submitted <b><i>guests</i></b> array. A direct request can vary casing to bypass <b><i>BLACKLISTED_GUEST_EMAILS</i></b> or submit differently cased and repeated addresses, causing <b><i>createMany</i></b> to insert multiple attendee rows that each reach calendar and email processing because the server schema does not enforce uniqueness. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Guest addresses are compared without normalization or request-level deduplication, allowing casing changes to bypass the blacklist and repeated or differently cased values to create multiple attendee records. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-103] - packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6] ## Recommended Fix Normalize all submitted guest addresses and existing attendee addresses to lowercase before comparison, deduplicate the normalized request server-side, and reject or consistently omit blocked and existing addresses before calling `createMany`. Where compatible with existing attendee data, enforce the same uniqueness invariant with an appropriate persistence constraint. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:78
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 5\. Blocked guest addresses bypass the blacklist <code>🐞 Bug</code> <code>⛨ Security</code> <pre> <b><i>uniqueGuests</i></b> compares unnormalized submitted addresses against a lowercased blacklist and performs case-sensitive checks against existing attendees. Differently cased blocked, existing, or repeated addresses can pass these checks and be persisted as duplicate attendee records because the server schema validates syntax without normalizing input or enforcing uniqueness. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Guest addresses are compared without normalization against a lowercased blacklist and existing attendees, allowing case variants of blocked addresses and differently cased or repeated values to be persisted as duplicate attendee records. ## Fix Focus Areas - packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-78] - packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6] ## Recommended Fix Canonicalize all submitted guest and existing attendee email addresses to lowercase before blacklist, existing-attendee, and duplicate comparisons. Deduplicate the normalized request server-side, reject or consistently omit blocked and existing addresses, and persist or consistently compare the canonical representation. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
packages/emails/templates/attendee-add-guests-email.ts:25
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 9\. Some guests see another guest's time <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>AttendeeAddGuestsEmail</i></b> builds its subject with inherited <b><i>getFormattedDate()</i></b>, whose timezone and locale are taken from <b><i>calEvent.attendees[0]</i></b> rather than the recipient passed to the email. When existing attendees have different locale or timezone settings, their add-guests subject displays the first attendee&#x27;s localized date and time. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The new attendee notification subject formats the meeting date using the first event attendee rather than the notification recipient. ## Fix Focus Areas - packages/emails/templates/attendee-add-guests-email.ts[22-25] ## Recommended Fix Format the subject date using `this.attendee`'s locale and timezone, matching the recipient-specific settings used by the email rendering path. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>PR Summary by Qodo</h3> Add guests to existing bookings with calendar and email updates <code>✨ Enhancement</code> <code>🕐 40+ Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Lets authorized booking participants add multiple validated guests from the booking actions menu. >• Persists attendees and synchronizes updated guest lists with connected calendar providers. >• Sends localized ICS notifications to organizers, existing attendees, and newly added guests. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid graph TD List["Booking actions"] --> Dialog["Guest dialog"] --> API["Bookings API"] --> Handler["Add guests"] --> DB[("Booking data")] Handler --> Calendar["Calendar providers"] Handler --> Email["Email delivery"] ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Shared booking-update service</b></summary> <dl> <dd> - ➕ Centralizes CalendarEvent construction used by similar booking mutations - ➕ Improves consistency for authorization, logging, and integration error handling - ➕ Makes orchestration easier to unit test independently of tRPC - ➖ Requires refactoring existing booking handlers beyond this feature - ➖ Increases the initial scope and migration risk </dd> </dl> </details> <details> <summary><b>2. Transactional outbox for integrations</b></summary> <dl> <dd> - ➕ Reliably retries calendar and email operations after attendee persistence - ➕ Reduces mutation latency and avoids losing notifications on transient failures - ➖ Introduces queue or worker infrastructure and operational complexity - ➖ Makes calendar and email propagation eventually consistent </dd> </dl> </details> >**Recommendation:** The current tRPC handler plus EventManager and existing email infrastructure is appropriate for this scoped enhancement and aligns with nearby booking-update flows. A shared booking-update service is the strongest follow-up if more mutations need the same event reconstruction; an outbox is warranted only if stronger cross-system delivery guarantees are required. </dd> </dl> </details> <details> <summary> Files changed (15) <code> +555 / -0 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (14) <code> +549 / -0 </code></summary> <dl> <dd> <details> <summary>BookingListItem.tsx<code>Expose the add-guests booking action</code> <code>+15/-0</code></summary> <br/> >Expose the add-guests booking action > ><pre> >• Adds an additional-guests menu action, tracks dialog visibility, and mounts AddGuestsDialog for the selected booking. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-178e89024734f552c5fa0953359ded5880f0e6975ae88e7bb085b3908c762abd'>apps/web/components/booking/BookingListItem.tsx</a> </details> <details> <summary>AddGuestsDialog.tsx<code>Add a dialog for entering booking guests</code> <code>+107/-0</code></summary> <br/> >Add a dialog for entering booking guests > ><pre> >• Introduces a localized dialog for collecting multiple email addresses, rejecting invalid or duplicate values, invoking the addGuests mutation, and refreshing booking queries after success. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-29eba270ad24802d859de809eddb2883ee3f8f56d964b77a5971eff2c61ddccf'>apps/web/components/dialog/AddGuestsDialog.tsx</a> </details> <details> <summary>email-manager.ts<code>Orchestrate guest-addition notifications</code> <code>+28/-0</code></summary> <br/> >Orchestrate guest-addition notifications > ><pre> >• Adds sendAddGuestsEmails to notify organizers and team members, send standard invitations to new guests, and inform existing attendees about the changed guest list. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-e050f389e47b0852bb18c45ae1ab76ed2c891ab0aa66326ff077dfd35abb8b3f'>packages/emails/email-manager.ts</a> </details> <details> <summary>AttendeeAddGuestsEmail.tsx<code>Add the attendee guest-update React template</code> <code>+10/-0</code></summary> <br/> >Add the attendee guest-update React template > ><pre> >• Specializes the scheduled-attendee email layout with guest-added heading and subject translations. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-82affbc53684b75cb0af00217504cfc1a7ecd69025819ebc73aa5e20ff3e488b'>packages/emails/src/templates/AttendeeAddGuestsEmail.tsx</a> </details> <details> <summary>OrganizerAddGuestsEmail.tsx<code>Add the organizer guest-update React template</code> <code>+11/-0</code></summary> <br/> >Add the organizer guest-update React template > ><pre> >• Specializes the organizer scheduled-email layout for guest additions and removes the standard call to action. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-cc26dd795fc419ddd80c6cdfd66bd09844feceb8beeae846761955f8d72922df'>packages/emails/src/templates/OrganizerAddGuestsEmail.tsx</a> </details> <details> <summary>index.ts<code>Export guest-addition React templates</code> <code>+2/-0</code></summary> <br/> >Export guest-addition React templates > ><pre> >• Makes the organizer and attendee guest-update templates available through the template package entry point. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-d0ff5c7164f306912fb5e3a78c83a1397c8112d204e67e4e07f4a94a03c69c7e'>packages/emails/src/templates/index.ts</a> </details> <details> <summary>attendee-add-guests-email.ts<code>Build attendee guest-update email payloads</code> <code>+34/-0</code></summary> <br/> >Build attendee guest-update email payloads > ><pre> >• Adds the mailer class for existing attendees, including localized content and a confirmed ICS event containing the updated attendee list. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-f93353bec39e150978e3b24b7a1e8285989198f183eb1d4f11a38d4a689447b8'>packages/emails/templates/attendee-add-guests-email.ts</a> </details> <details> <summary>organizer-add-guests-email.ts<code>Build organizer guest-update email payloads</code> <code>+38/-0</code></summary> <br/> >Build organizer guest-update email payloads > ><pre> >• Adds the organizer and team-member mailer payload with localized content, reply-to recipients, and an updated confirmed ICS event. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-01be41b15c49b0a994c67438b10b76d4daa1296c15ac19be6a2bb52272a708d2'>packages/emails/templates/organizer-add-guests-email.ts</a> </details> <details> <summary>_router.tsx<code>Register the authenticated addGuests mutation</code> <code>+19/-0</code></summary> <br/> >Register the authenticated addGuests mutation > ><pre> >• Adds the addGuests input schema and lazily loaded mutation handler to the viewer bookings router. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-2ddf19d6e8a3222f4f324e1b6d4864745fd56ddf5112f7ff4c39fd2952a0e3ec'>packages/trpc/server/routers/viewer/bookings/_router.tsx</a> </details> <details> <summary>addGuests.handler.ts<code>Implement guest persistence and integration synchronization</code> <code>+174/-0</code></summary> <br/> >Implement guest persistence and integration synchronization > ><pre> >• Authorizes eligible users, filters existing or blacklisted addresses, creates attendees, reconstructs the calendar event, updates connected calendars, and dispatches guest-addition emails. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9'>packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts</a> </details> <details> <summary>addGuests.schema.ts<code>Define addGuests mutation input validation</code> <code>+8/-0</code></summary> <br/> >Define addGuests mutation input validation > ><pre> >• Adds the shared tRPC schema requiring a numeric booking identifier and an array of valid guest email addresses. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-98fbb1d8a93aeb2e933b44ca92d3d6c4a9c6b4a9b2d30d9690e43025d4e57448'>packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts</a> </details> <details> <summary>MultiEmail.tsx<code>Add a reusable multi-email form control</code> <code>+96/-0</code></summary> <br/> >Add a reusable multi-email form control > ><pre> >• Introduces a controlled list of email fields with add and remove actions, read-only support, and localized controls. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-d92deb9d4f618b645401f68d1a5dc4ff440bc949ac475753798c5b3f344934b7'>packages/ui/form/MultiEmail.tsx</a> </details> <details> <summary>MultiEmailLazy.tsx<code>Lazy-load the multi-email control</code> <code>+6/-0</code></summary> <br/> >Lazy-load the multi-email control > ><pre> >• Adds a Next.js dynamic import wrapper to avoid loading the multi-email component for users who do not need it. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-6396c9e635b638b80bc90153e8d7b32e13968538c6068bd17b0ea334bdd94f04'>packages/ui/form/MultiEmailLazy.tsx</a> </details> <details> <summary>index.tsx<code>Export MultiEmail from the UI package</code> <code>+1/-0</code></summary> <br/> >Export MultiEmail from the UI package > ><pre> >• Exposes the lazy-loaded MultiEmail control through the public UI package entry point. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-467f39257eabeb3c7609369b74968acfe95ff4760e84102bfa3bac6620f77291'>packages/ui/index.tsx</a> </details> </dd> </dl> </details> <details> <summary>Other (1) <code> +6 / -0 </code></summary> <dl> <dd> <details> <summary>common.json<code>Add English guest-update translations</code> <code>+6/-0</code></summary> <br/> >Add English guest-update translations > ><pre> >• Adds labels, validation messages, toast text, and email subject and heading strings for the add-guests workflow. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-57de4b8e5231f1d699891d98b0381d56e9e24537b0ca5420d1fba4f0597370bc'>apps/web/public/static/locales/en/common.json</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (9)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Calendar updates use the wrong account <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>addGuestsHandler</i></b> persists attendees, then constructs <b><i>EventManager</i></b> with <b><i>ctx.user</i></b> and the >caller&#x27;s credentials instead of the booking organizer&#x27;s credential context, while also ignoring the >calendar update result. When an authorized attendee or team user updates a calendar reference >without <b><i>credentialId</i></b> or without a matching caller credential, the organizer&#x27;s external calendar >can be skipped or accessed through the caller&#x27;s same-type account after the database rows have >already been committed. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R158-163]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R158-R163)</code> > >```diff >+ const credentials = await getUsersCredentials(ctx.user); >+ >+ const eventManager = new EventManager({ >+ ...user, >+ credentials: [...credentials], >+ }); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The route explicitly permits attendees and team roles in addition to the organizer, but scopes >credential lookup to the authenticated caller. <b><i>EventManager</i></b> filters updates using those supplied >credentials and falls back to its own same-type credentials when a calendar reference lacks a >credential ID; if no matching credential is available, it does not throw, and the handler has >already persisted the attendees before disregarding the update outcome. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[50-55]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L50-L55)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L158-L165)</code> > <code>[packages/core/EventManager.ts[845-878]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/core/EventManager.ts/#L845-L878)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[50-56]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L50-L56)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L92-L106)</code> > <code>[packages/lib/server/getUsersCredentials.ts[8-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/lib/server/getUsersCredentials.ts/#L8-L18)</code> > <code>[packages/core/EventManager.ts[872-938]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/core/EventManager.ts/#L872-L938)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Calendar synchronization uses the authenticated caller's credentials rather than the booking organizer's credentials and does not verify the update result, allowing permitted non-organizer callers to persist guests without reliably updating the organizer's external calendar. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106] >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165] > >## Recommended Fix >Load the booking organizer's full calendar credential context and construct `EventManager` with the organizer's identity, retaining the authenticated caller only for authorization and audit purposes. Ensure calendar update failures fail the mutation before attendee rows are committed, or compensate for any already-persisted rows when the external update fails. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 2. Failed calendar sync still reports success <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>addGuestsHandler</i></b> commits attendee rows, initializes <b><i>EventManager</i></b> with <b><i>ctx.user</i></b> credentials >rather than the booking organizer’s, and ignores the result of <b><i>updateCalendarAttendees</i></b>, which >silently returns for missing references and converts update exceptions into unsuccessful results. >When a permitted attendee or team user lacks matching calendar credentials, the external event can >remain unchanged while the handler continues to send guest notifications and return success. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R165-168]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R165-R168)</code> > >```diff >+ await eventManager.updateCalendarAttendees(evt, booking); >+ >+ try { >+ await sendAddGuestsEmails(evt, guests); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The route authorizes attendees and team users, but calendar credential lookup is scoped to the >calling user and <b><i>EventManager</i></b> filters updates using those credentials. Because the handler >persists attendees before synchronization, while <b><i>updateCalendarAttendees</i></b> neither throws when no >matching credential or reference exists nor propagates update exceptions, disregarding its result >allows the handler to continue to notification and a successful response despite failed calendar >synchronization. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L92-L106)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[165-173]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L165-L173)</code> > <code>[packages/core/EventManager.ts[596-602]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/core/EventManager.ts/#L596-L602)</code> > <code>[packages/core/EventManager.ts[920-938]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/core/EventManager.ts/#L920-L938)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[50-56]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L50-L56)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L158-L165)</code> > <code>[packages/lib/server/getUsersCredentials.ts[8-18]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/lib/server/getUsersCredentials.ts/#L8-L18)</code> > <code>[packages/core/EventManager.ts[872-938]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/core/EventManager.ts/#L872-L938)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The mutation uses the caller’s calendar credentials and reports success after persisting attendees without verifying external calendar synchronization, allowing permitted non-organizer callers to add guests without updating the organizer’s calendar. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[92-106] >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[158-165] >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[165-173] >- packages/core/EventManager.ts[596-602] > >## Recommended Fix >Load the booking organizer’s calendar credentials for the update and return and inspect synchronization results from `updateCalendarAttendees`. Require the necessary calendar updates to succeed before committing attendee rows and sending notifications, or compensate already-persisted rows and durably retry or surface synchronization failures so the database and external calendar cannot silently diverge. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 3. Team admins cannot add guests <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>isTeamAdminOrOwner</i></b> combines <b><i>isTeamAdmin(user.id, teamId)</i></b> and <b><i>isTeamOwner(user.id, teamId)</i></b> with ><b><i>&amp;&amp;</i></b>, so the owner-only predicate negates the admin access already covered by the former. A >non-owner team admin who is neither the booking organizer nor an attendee can see team bookings and >the new action, but submitting the dialog reaches the <b><i>FORBIDDEN</i></b> branch. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R46-48]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R46-R48)</code> > >```diff >+ const isTeamAdminOrOwner = >+ (await isTeamAdmin(user.id, booking.eventType?.teamId ?? 0)) && >+ (await isTeamOwner(user.id, booking.eventType?.teamId ?? 0)); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The handler requires both role predicates to succeed, while the team query defines <b><i>isTeamAdmin</i></b> as >accepting ADMIN and OWNER memberships and <b><i>isTeamOwner</i></b> as accepting only OWNER memberships. The >booking list includes team bookings for ADMIN users and exposes the action to them, proving that >ordinary administrators are accepted as booking managers elsewhere but rejected by this handler. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[46-55]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L46-L55)</code> > <code>[packages/lib/server/queries/teams/index.ts[264-295]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/lib/server/queries/teams/index.ts/#L264-L295)</code> > <code>[packages/trpc/server/routers/viewer/bookings/get.handler.ts[274-296]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/get.handler.ts/#L274-L296)</code> > <code>[apps/web/components/booking/BookingListItem.tsx[194-200]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/apps/web/components/booking/BookingListItem.tsx/#L194-L200)</code> > <code>[packages/lib/server/queries/teams/index.ts[264-294]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/lib/server/queries/teams/index.ts/#L264-L294)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The add-guests team-role check requires a user to be both an admin and an owner, rejecting valid non-owner team administrators. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[46-55] > >## Recommended Fix >Authorize the operation when either `isTeamAdmin` or `isTeamOwner` succeeds, following the repository's existing team-management authorization pattern. Preserve the organizer and attendee authorization paths. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details><summary><ins><strong>View high (2)</strong></ins></summary><br/> <details> <summary> 4. Guests receive duplicate invitations <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>uniqueGuests</i></b> compares unnormalized input against a lowercased blacklist and existing attendees >case-sensitively, while checking only attendees loaded before the mutation rather than deduplicating >the submitted <b><i>guests</i></b> array. A direct request can vary casing to bypass <b><i>BLACKLISTED_GUEST_EMAILS</i></b> >or submit differently cased and repeated addresses, causing <b><i>createMany</i></b> to insert multiple attendee >rows that each reach calendar and email processing because the server schema does not enforce >uniqueness. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R74-78]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R74-R78)</code> > >```diff >+ const uniqueGuests = guests.filter( >+ (guest) => >+ !booking.attendees.some((attendee) => guest === attendee.email) && >+ !blacklistedGuestEmails.includes(guest) >+ ); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The input schema permits arbitrary email arrays, but the filtering predicate does not normalize >submitted addresses, compares them against an explicitly lowercased blacklist and existing >attendees, and only considers attendees that existed before the mutation. Every value that survives >is passed to <b><i>createMany</i></b>, the attendee model has only a non-unique email index, and downstream >email dispatch iterates over every resulting attendee, demonstrating that blacklist bypasses and >duplicate rows propagate into later processing. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts/#L3-L6)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[74-78]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L74-L78)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[99-120]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L99-L120)</code> > <code>[packages/emails/email-manager.ts[539-547]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/email-manager.ts/#L539-L547)</code> > <code>[packages/prisma/schema.prisma[526-538]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/prisma/schema.prisma/#L526-L538)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-78]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L70-L78)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[100-105]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L100-L105)</code> > <code>[packages/prisma/schema.prisma[526-539]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/prisma/schema.prisma/#L526-L539)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Guest addresses are compared without normalization or request-level deduplication, allowing casing changes to bypass the blacklist and repeated or differently cased values to create multiple attendee records. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-103] >- packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6] > >## Recommended Fix >Normalize all submitted guest addresses and existing attendee addresses to lowercase before comparison, deduplicate the normalized request server-side, and reject or consistently omit blocked and existing addresses before calling `createMany`. Where compatible with existing attendee data, enforce the same uniqueness invariant with an appropriate persistence constraint. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 5. Blocked guest addresses bypass the blacklist <code>🐞 Bug</code> <code>⛨ Security</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>uniqueGuests</i></b> compares unnormalized submitted addresses against a lowercased blacklist and performs >case-sensitive checks against existing attendees. Differently cased blocked, existing, or repeated >addresses can pass these checks and be persisted as duplicate attendee records because the server >schema validates syntax without normalizing input or enforcing uniqueness. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R70-78]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R70-R78)</code> > >```diff >+ const blacklistedGuestEmails = process.env.BLACKLISTED_GUEST_EMAILS >+ ? process.env.BLACKLISTED_GUEST_EMAILS.split(",").map((email) => email.toLowerCase()) >+ : []; >+ >+ const uniqueGuests = guests.filter( >+ (guest) => >+ !booking.attendees.some((attendee) => guest === attendee.email) && >+ !blacklistedGuestEmails.includes(guest) >+ ); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The code explicitly lowercases configured blacklist values but leaves submitted guest addresses >unchanged, while Zod validates only email syntax and does not normalize casing. Every value that >survives the case-sensitive filtering is inserted, and the attendee model has only a non-unique >email index, showing that neither request processing nor the database prevents differently cased or >repeated attendee records. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-78]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L70-L78)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts/#L3-L6)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[100-105]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L100-L105)</code> > <code>[packages/prisma/schema.prisma[526-539]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/prisma/schema.prisma/#L526-L539)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Guest addresses are compared without normalization against a lowercased blacklist and existing attendees, allowing case variants of blocked addresses and differently cased or repeated values to be persisted as duplicate attendee records. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[70-78] >- packages/trpc/server/routers/viewer/bookings/addGuests.schema.ts[3-6] > >## Recommended Fix >Canonicalize all submitted guest and existing attendee email addresses to lowercase before blacklist, existing-attendee, and duplicate comparisons. Deduplicate the normalized request server-side, reject or consistently omit blocked and existing addresses, and persist or consistently compare the canonical representation. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> </details> <br/> <img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> <details> <summary> 6. Existing guests get booking confirmations <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>addGuestsHandler</i></b> filters existing attendees out of <b><i>uniqueGuests</i></b> but passes the original <b><i>guests</i></b> >input to <b><i>sendAddGuestsEmails</i></b>. When a request contains both an existing address and a new address, >the existing attendee is classified as newly added and receives a fresh scheduled-booking email >instead of the guest-change notification. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R167-168]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R167-R168)</code> > >```diff >+ try { >+ await sendAddGuestsEmails(evt, guests); >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Existing attendees are removed before insertion, but the original input drives the mailer&#x27;s ><b><i>newGuests.includes</i></b> branch that selects the scheduled email. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[74-78]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L74-L78)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-168]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L167-L168)</code> > <code>[packages/emails/email-manager.ts[539-547]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/email-manager.ts/#L539-L547)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Notification classification uses the unfiltered request rather than the addresses actually inserted into the booking. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[74-78] >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-168] >- packages/emails/email-manager.ts[539-547] > >## Recommended Fix >Pass the normalized `uniqueGuests` collection to `sendAddGuestsEmails` so only attendees inserted by this mutation receive scheduled-booking notifications. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 7. Team emails use the organizer&#x27;s locale <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>OrganizerAddGuestsEmail</i></b> receives a <b><i>teamMember</i></b> recipient but omits that value from the props >passed to the React email template. Team-member notifications consequently render their body with >the organizer&#x27;s locale and time zone, and the inherited class also builds the subject, text, and >calendar attachment from the organizer&#x27;s translation function. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/emails/templates/organizer-add-guests-email.ts[R31-34]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-01be41b15c49b0a994c67438b10b76d4daa1296c15ac19be6a2bb52272a708d2R31-R34)</code> > >```diff >+ html: await renderEmail("OrganizerAddGuestsEmail", { >+ attendee: this.calEvent.organizer, >+ calEvent: this.calEvent, >+ }), >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The manager creates one email instance per team member, but the new template does not forward that >member; the React template only selects recipient-specific locale and time-zone values when the prop >is supplied. ></pre> > > <code>[packages/emails/email-manager.ts[531-535]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/email-manager.ts/#L531-L535)</code> > <code>[packages/emails/templates/organizer-add-guests-email.ts[31-34]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/templates/organizer-add-guests-email.ts/#L31-L34)</code> > <code>[packages/emails/src/templates/OrganizerScheduledEmail.tsx[31-45]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/src/templates/OrganizerScheduledEmail.tsx/#L31-L45)</code> > <code>[packages/emails/templates/organizer-scheduled-email.ts[20-26]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/templates/organizer-scheduled-email.ts/#L20-L26)</code> > <code>[packages/emails/templates/organizer-scheduled-email.ts[51-56]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/templates/organizer-scheduled-email.ts/#L51-L56)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Team-member add-guests emails are rendered and formatted using the organizer's locale rather than the recipient's locale and time zone. > >## Fix Focus Areas >- packages/emails/templates/organizer-add-guests-email.ts[7-35] >- packages/emails/src/templates/OrganizerScheduledEmail.tsx[31-45] > >## Recommended Fix >Forward `this.teamMember` into the React template and initialize recipient-sensitive translation, time-zone formatting, text, subject, and calendar content from the team member when one is present. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 8. Email failures lose their traceback <code>🐞 Bug</code> <code>◔ Observability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The notification catch block discards <b><i>err</i></b> and writes only a fixed string through <b><i>console.log</i></b>. >Any rendering, transport, or recipient failure therefore leaves no exception message or traceback >with which operators can diagnose the unsuccessful delivery. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[R167-171]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-1694bafd24eb9cd84e08bff27be47dac138107b0981cb506ee002c477c9159e9R167-R171)</code> > >```diff >+ try { >+ await sendAddGuestsEmails(evt, guests); >+ } catch (err) { >+ console.log("Error sending AddGuestsEmails"); >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The newly added catch receives <b><i>err</i></b> but never includes it in the emitted message, so every failure >is represented by the same context-free log line. ></pre> > > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-171]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L167-L171)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Add-guests notification failures are swallowed with a static console message that omits the exception and booking context. > >## Fix Focus Areas >- packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[167-171] > >## Recommended Fix >Use the repository's structured logger to record the caught exception with its traceback plus booking and recipient context, while preserving the intended best-effort notification behavior. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details><summary><ins><strong>View medium (1)</strong></ins></summary><br/> <details> <summary> 9. Some guests see another guest&#x27;s time <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>AttendeeAddGuestsEmail</i></b> builds its subject with inherited <b><i>getFormattedDate()</i></b>, whose timezone and >locale are taken from <b><i>calEvent.attendees[0]</i></b> rather than the recipient passed to the email. When >existing attendees have different locale or timezone settings, their add-guests subject displays the >first attendee&#x27;s localized date and time. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[packages/emails/templates/attendee-add-guests-email.ts[R22-25]](https://github.com/drape-io/crbench-qodo-2026-09/pull/19/files#diff-f93353bec39e150978e3b24b7a1e8285989198f183eb1d4f11a38d4a689447b8R22-R25)</code> > >```diff >+ subject: `${this.t("guests_added_event_type_subject", { >+ eventType: this.calEvent.type, >+ name: this.calEvent.team?.name || this.calEvent.organizer.name, >+ date: this.getFormattedDate(), >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The newly added template invokes the inherited formatter for a recipient-specific email. That >formatter derives both timezone and locale from the first calendar attendee, while this handler >builds attendee records with individual timezone and locale values. ></pre> > > <code>[packages/emails/templates/attendee-add-guests-email.ts[22-25]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/templates/attendee-add-guests-email.ts/#L22-L25)</code> > <code>[packages/emails/templates/attendee-scheduled-email.ts[76-84]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/templates/attendee-scheduled-email.ts/#L76-L84)</code> > <code>[packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts[108-120]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts/#L108-L120)</code> > <code>[packages/emails/src/templates/AttendeeScheduledEmail.tsx[11-17]](https://github.com/drape-io/crbench-qodo-2026-09/blob/812aaf9edfaf0109a957cd6b02e1806027e2943f/packages/emails/src/templates/AttendeeScheduledEmail.tsx/#L11-L17)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The new attendee notification subject formats the meeting date using the first event attendee rather than the notification recipient. > >## Fix Focus Areas >- packages/emails/templates/attendee-add-guests-email.ts[22-25] > >## Recommended Fix >Format the subject date using `this.attendee`'s locale and timezone, matching the recipient-specific settings used by the email rendering path. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>🧠 Deep</code>: This adds a new booking mutation spanning authorization, attendee/calendar updates, and multiple email/UI paths, with substantial independent logic and several easy-to-miss correctness and permission risks.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/812aaf9edfaf0109a957cd6b02e1806027e2943f --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>