From bec49ef417818381df4b50653914dfe05f1b52e5 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Thu, 9 Oct 2025 14:28:57 +0530 Subject: [PATCH] fix: provide meetingStartTime for test preview to prevent 'Meeting start time is required' crash (#24379) * fix: provide meetingStartTime for test preview to prevent RR timestamp error When Round Robin timestamp basis is set to START_TIME, the system requires a meeting start time to calculate the interval for load balancing. Test Preview doesn't have a real meeting time since it's just simulating the routing logic. This fix provides the current time (new Date()) as the meetingStartTime when calling getOrderedListOfLuckyUsers in test preview mode. This allows the Round Robin calculation to proceed using the current interval for realistic ordering while still being in preview mode. Fixes the 'Meeting start time is required' error that occurs when users click Test Preview on routing forms with Round Robin timestamp basis set to START_TIME. Co-Authored-By: hariom@cal.com * add comment --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../findTeamMembersMatchingAttributeLogicOfRoute.handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts b/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts index 413ec38a47..ab5924c805 100644 --- a/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts +++ b/packages/trpc/server/routers/viewer/routing-forms/findTeamMembersMatchingAttributeLogicOfRoute.handler.ts @@ -7,9 +7,9 @@ import type { ServerResponse } from "http"; import type { NextApiResponse } from "next"; import { enrichFormWithMigrationData } from "@calcom/app-store/routing-forms/enrichFormWithMigrationData"; +import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import { getUrlSearchParamsToForwardForTestPreview } from "@calcom/features/routing-forms/lib/getUrlSearchParamsToForward"; import { enrichHostsWithDelegationCredentials } from "@calcom/lib/delegationCredential/server"; -import { getLuckyUserService } from "@calcom/features/di/containers/LuckyUser"; import { entityPrismaWhereClause } from "@calcom/lib/entityPermissionUtils.server"; import { fromEntriesWithDuplicateKeys } from "@calcom/lib/fromEntriesWithDuplicateKeys"; import { findTeamMembersMatchingAttributeLogic } from "@calcom/lib/raqb/findTeamMembersMatchingAttributeLogic"; @@ -296,6 +296,8 @@ export const findTeamMembersMatchingAttributeLogicOfRouteHandler = async ({ form, chosenRouteId: route.id, }, + // During Preview testing we could consider the current time itself as the meeting start time + meetingStartTime: new Date(), }) : { users: [], perUserData: null, isUsingAttributeWeights: false }; const timeAfterGetOrderedLuckyUsers = performance.now();