{"record":{"id":"a96be27ac551fc41","repo":"calcom/cal.diy","slug":"cannot-reserve-a-slot-for-a-team-event-without-any","errorCode":null,"errorMessage":"Cannot reserve a slot for a team event without any hosts","messagePattern":"Cannot reserve a slot for a team event without any hosts","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts","lineNumber":187,"sourceCode":"    }\n\n    const reservationDuration = input.reservationDuration ?? DEFAULT_RESERVATION_DURATION;\n\n    if (eventType.userId) {\n      const slot = await this.slotsRepository.createSlot(\n        eventType.userId,\n        eventType.id,\n        startDate.toISO(),\n        endDate.toISO(),\n        eventType.seatsPerTimeSlot !== null,\n        reservationDuration\n      );\n      return this.slotsOutputService.getReservationSlotCreated(slot, reservationDuration);\n    }\n\n    const host = eventType.hosts[0];\n    if (!host) {\n      throw new BadRequestException(\"Cannot reserve a slot for a team event without any hosts\");\n    }\n\n    const slot = await this.slotsRepository.createSlot(\n      host.userId,\n      eventType.id,\n      startDate.toISO(),\n      endDate.toISO(),\n      eventType.seatsPerTimeSlot !== null,\n      reservationDuration\n    );\n\n    return this.slotsOutputService.getReservationSlotCreated(slot, reservationDuration);\n  }\n\n  private async checkSlotOverlap(eventTypeId: number, startDate: string, endDate: string) {\n    const overlappingReservation = await this.slotsRepository.getOverlappingSlotReservation(\n      eventTypeId,\n      startDate,","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts#L169-L205","documentation":"A NestJS BadRequestException (HTTP 400) from SlotsService_2024_09_04.reserveSlot. The event type is a team event (no eventType.userId) and eventType.hosts[0] is undefined — the team event has zero hosts assigned. The reserve flow needs a host to attach the slot to, so it refuses.","triggerScenarios":"POST /v2/slots/reserve for a team event type whose hosts array is empty — all members were removed, or the event type was created without assigning hosts.","commonSituations":"Team event configured but no members added; hosts transferred out of the team; race between team setup and a reserve call; misconfigured round-robin event with an empty host list.","solutions":["Assign at least one host to the team event type in the Cal.com dashboard before reserving.","Verify via GET /v2/event-types that hosts.length > 0 before calling reserve.","Surface a 'no hosts available' message and ask the event owner to add members.","If hosts exist in the DB but are not loaded, check the repository includes hosts in the query."],"exampleFix":"// before\nawait reserve(teamEventTypeId, slotStart); // hosts: []\n\n// after\nconst et = await calApi.eventTypes.getById(teamEventTypeId);\nif (!et.hosts?.length) throw new ClientError('Team event has no hosts — ask owner to add members');\nawait reserve(teamEventTypeId, slotStart);","handlingStrategy":"validation","validationCode":"async function assertTeamEventHasHosts(eventTypeId: number) {\n  const et = await cal.eventTypes.getById(eventTypeId);\n  if (!et) throw new ClientError('Event type not found');\n  if (et.teamId && !(et.hosts?.length)) {\n    throw new UserFacingError('Team event has no hosts — ask the owner to add members.');\n  }\n  return et;\n}\nawait assertTeamEventHasHosts(eventTypeId);","typeGuard":"function teamEventHasHosts(et: { teamId?: number | null; hosts?: unknown[] }): boolean {\n  return !et.teamId || (Array.isArray(et.hosts) && et.hosts.length > 0);\n}","tryCatchPattern":"try {\n  await cal.slots.reserve({ eventTypeId, slotStart });\n} catch (e) {\n  if (e instanceof HttpError && e.statusCode === 400 && /without any hosts/i.test(e.message)) {\n    throw new UserFacingError('This team event has no hosts yet — please contact the organizer.');\n  }\n  throw e;\n}","preventionTips":["Verify hosts.length > 0 before reserving team events.","Surface a configuration error to the event owner.","Add at least one host when creating team/round-robin event types.","Confirm the repository query includes hosts."],"tags":["calcom-api","slots","bad-request","team-event","hosts","configuration"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}