Skip to content

Scheduling infrastructure for absolutely everyone.

fix: add validation for empty hosts in round robin reassignment (#22429)

devin-ai-integration[bot]0207109612a5
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 0738b76b951..5bc7990ab03 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -3361,5 +3361,6 @@
"license_validation_failed": "Failed to validate license key",
"license_key_saved": "License key saved successfully",
"timezone_mismatch_tooltip": "You are viewing the report based on your profile timezone ({{userTimezone}}), while your browser is set to timezone ({{browserTimezone}})",
+ "event_type_no_hosts": "No hosts are assigned to event type",
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
}
diff --git a/packages/features/ee/round-robin/roundRobinReassignment.ts b/packages/features/ee/round-robin/roundRobinReassignment.ts
index 660e91c86be..47bf2545934 100644
--- a/packages/features/ee/round-robin/roundRobinReassignment.ts
+++ b/packages/features/ee/round-robin/roundRobinReassignment.ts
@@ -20,6 +20,7 @@ import {
enrichHostsWithDelegationCredentials,
enrichUserWithDelegationCredentialsIncludeServiceAccountKey,
} from "@calcom/lib/delegationCredential/server";
+import { ErrorCode } from "@calcom/lib/errorCodes";
import { getEventName } from "@calcom/lib/event";
import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService";
import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj";
@@ -99,6 +100,10 @@ export const roundRobinReassignment = async ({
createdAt: new Date(0), // use earliest possible date as fallback
}));
+ if (eventType.hosts.length === 0) {
+ throw new Error(ErrorCode.EventTypeNoHosts);
+ }
+
const roundRobinHosts = eventType.hosts.filter((host) => !host.isFixed);
const originalOrganizer = booking.user;
diff --git a/packages/lib/errorCodes.ts b/packages/lib/errorCodes.ts
index 6f7cb7f0569..b96691491ee 100644
--- a/packages/lib/errorCodes.ts
+++ b/packages/lib/errorCodes.ts
@@ -23,4 +23,5 @@ export enum ErrorCode {
BookerLimitExceededReschedule = "booker_limit_exceeded_error_reschedule",
BookingNotAllowedByRestrictionSchedule = "booking_not_allowed_by_restriction_schedule_error",
RestrictionScheduleNotFound = "restriction_schedule_not_found_error",
+ EventTypeNoHosts = "event_type_no_hosts",
}
diff --git a/packages/lib/server/getServerErrorFromUnknown.ts b/packages/lib/server/getServerErrorFromUnknown.ts
index abafecdcfc0..df5b63f5a4a 100644
--- a/packages/lib/server/getServerErrorFromUnknown.ts
+++ b/packages/lib/server/getServerErrorFromUnknown.ts
@@ -111,6 +111,7 @@ function getStatusCode(cause: Error | ErrorWithCode): number {
case ErrorCode.BookingNotAllowedByRestrictionSchedule:
case ErrorCode.BookerLimitExceeded:
case ErrorCode.BookerLimitExceededReschedule:
+ case ErrorCode.EventTypeNoHosts:
return 400;
// 409 Conflict
case ErrorCode.NoAvailableUsersFound: