Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/features/bookings/lib/payment/getBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export async function getBooking(bookingId: number) {
type: booking?.eventType?.slug as string,
title: booking.title,
bookerUrl,
description: booking.description || undefined,
description: booking.eventType?.description || "",
additionalNotes: booking.description || null,
startTime: booking.startTime.toISOString(),
endTime: booking.endTime.toISOString(),
customInputs: isPrismaObjOrUndefined(booking.customInputs),
Expand Down
7 changes: 5 additions & 2 deletions packages/lib/__tests__/buildCalEventFromBooking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ const createAttendee = (overrides = {}) => ({

const createBooking = (overrides = {}) => ({
title: "Test Booking",
description: "Test Description",
description: "Test Attendee Notes",
startTime: new Date("2023-04-01T10:00:00Z"),
endTime: new Date("2023-04-01T11:00:00Z"),
userPrimaryEmail: "user@example.com",
uid: "test-uid",
attendees: [createAttendee()],
eventType: {
title: "Test Event Type",
description: "Test Event Type Description",
seatsPerTimeSlot: 5,
seatsShowAttendees: true,
recurringEvent: {
Expand Down Expand Up @@ -96,7 +97,8 @@ describe("buildCalEventFromBooking", () => {
expect(result).toEqual({
title: booking.title,
type: booking.eventType.title,
description: booking.description,
description: booking.eventType.description,
additionalNotes: booking.description,
startTime: dayjs(booking.startTime).format(),
endTime: dayjs(booking.endTime).format(),
organizer: {
Expand Down Expand Up @@ -162,6 +164,7 @@ describe("buildCalEventFromBooking", () => {
title: booking.title,
type: "",
description: "",
additionalNotes: null,
startTime: "",
endTime: "",
organizer: {
Expand Down
4 changes: 3 additions & 1 deletion packages/lib/buildCalEventFromBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Organizer = {

type EventType = {
title: string;
description: string | null;
recurringEvent: Prisma.JsonValue | null;
seatsPerTimeSlot: number | null;
seatsShowAttendees: boolean | null;
Expand Down Expand Up @@ -91,7 +92,8 @@ export const buildCalEventFromBooking = async ({
return {
title: booking.title || "",
type: (booking.eventType?.title as string) || booking.title || "",
description: booking.description || "",
description: booking.eventType?.description || "",
additionalNotes: booking.description || null,
startTime: booking.startTime ? dayjs(booking.startTime).format() : "",
endTime: booking.endTime ? dayjs(booking.endTime).format() : "",
organizer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ export async function buildCalendarEvent(
const evt: CalendarEvent = {
title: booking.title || "",
type: (booking.eventType?.title as string) || booking?.title || "",
description: booking.description || "",
description: booking.eventType?.description || "",
additionalNotes: booking.description || null,
startTime: booking.startTime ? dayjs(booking.startTime).format() : "",
endTime: booking.endTime ? dayjs(booking.endTime).format() : "",
organizer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
const evt: CalendarEvent = {
type: booking?.eventType?.slug as string,
title: booking.title,
description: booking.description,
description: booking.eventType?.description || "",
additionalNotes: booking.description || null,
Comment on lines +320 to +321
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Duplicate additionalNotes property causes inconsistent behavior.

additionalNotes is assigned twice in this object literal:

  • Line 321: additionalNotes: booking.description || null (normalizes falsy values to null)
  • Line 368: additionalNotes: booking.description (raw value, no normalization)

Since line 368 comes after line 321, it overrides the first assignment. This creates a semantic difference: an empty string "" would be normalized to null on line 321 but passed through as "" on line 368.

This is inconsistent with the other files in this PR (buildCalEventFromBooking.ts, addGuests.handler.ts, getBooking.ts) which all use the || null normalization pattern.

🐛 Proposed fix: Remove the duplicate assignment
     ...(platformClientParams ? platformClientParams : {}),
     organizationId: organizerOrganizationId ?? booking.eventType?.team?.parentId ?? null,
-    additionalNotes: booking.description,
     assignmentReason: booking.assignmentReason?.[0]?.reasonEnum

Also applies to: 368-368

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/trpc/server/routers/viewer/bookings/confirm.handler.ts` around lines
320 - 321, The object literal in confirm.handler.ts defines additionalNotes
twice causing the later raw assignment additionalNotes: booking.description to
override the earlier normalized additionalNotes: booking.description || null;
remove the duplicate raw assignment (additionalNotes: booking.description) so
only the normalized additionalNotes: booking.description || null remains
(matching buildCalEventFromBooking, addGuests.handler, getBooking patterns).

bookerUrl,
// TODO: Remove the usage of `bookingFields` in computing responses. We can do that by storing `label` with the response. Also, this would allow us to correctly show the label for a field even after the Event Type has been deleted.
...getCalEventResponses({
Expand Down
Loading