From 52e1a589043a4bb297ecbec7840d41b795c7a67e Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:59:42 +0100 Subject: [PATCH] handle gracefully and log error (#17310) --- .../roundRobin/getRoundRobinHostsToReasign.handler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts b/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts index 96b87b9b8e..d220c8d0a0 100644 --- a/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts +++ b/packages/trpc/server/routers/viewer/teams/roundRobin/getRoundRobinHostsToReasign.handler.ts @@ -56,10 +56,19 @@ export const getRoundRobinHostsToReassign = async ({ ctx, input }: GetRoundRobin // Get event type const eventType = await getEventTypesFromDB(booking.eventType.id); - if (!eventType || !eventType.teamId) { + if (!eventType) { throw new Error("Event type not found"); } + if (!eventType.teamId) { + gettingRoundRobinHostsToReassignLogger.warn("Booking with event type that has no teamId", { + bookingId: input.bookingId, + eventTypeId: eventType.id, + teamId: eventType.teamId ?? -1, + }); + return []; + } + const availableEventTypeUsers = eventType.hosts .filter((h) => !h.isFixed && h.user.id !== booking.userId) .map((host) => ({