calcom/cal.diy · error · BadRequestException

Invalid seatUid: this seat does not exist or has already bee

Error message

Invalid seatUid: this seat does not exist or has already been cancelled.

What it means

Thrown by cancelBooking when the request body is identified as a seated-cancellation (isCancelSeatedBody true) but the referenced seatUid does not resolve to a seat via bookingSeatRepository.getByReferenceUid. BadRequestException (HTTP 400).

Source

Thrown at apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts:904

    return isOrgAdmin;
  }

  isRescheduleSeatedBody(body: RescheduleBookingInput): body is RescheduleSeatedBookingInput_2024_08_13 {
    return "seatUid" in body;
  }

  async cancelBooking(
    request: Request,
    bookingUid: string,
    body: CancelBookingInput,
    authUser: AuthOptionalUser
  ) {
    if (this.inputService.isCancelSeatedBody(body)) {
      const seat = await this.bookingSeatRepository.getByReferenceUid(body.seatUid);

      if (!seat) {
        throw new BadRequestException(
          "Invalid seatUid: this seat does not exist or has already been cancelled."
        );
      }

      if (seat && bookingUid !== seat.booking.uid) {
        throw new BadRequestException("Invalid seatUid: this seat does not belong to this booking.");
      }
    }

    const bookingRequest = await this.inputService.createCancelBookingRequest(request, bookingUid, body);
    const res = await handleCancelBooking({
      bookingData: bookingRequest.body,
      userId: bookingRequest.userId,
      userUuid: authUser?.uuid,
      actionSource: "API_V2",
      arePlatformEmailsEnabled: bookingRequest.arePlatformEmailsEnabled,
      platformClientId: bookingRequest.platformClientId,
      platformCancelUrl: bookingRequest.platformCancelUrl,

View on GitHub (pinned to 176037d0af)

Solutions

  1. Verify the seatUid is active by fetching the parent booking and inspecting its seats before cancelling.
  2. Guard against double-cancel: track local seat state and skip if already cancelled.
  3. Ensure the value is the seat reference uid, not the booking uid.

Example fix

// before
await client.delete(`/v2/bookings/${uid}`, { data: { seatUid: bookingUid } });
// after
await client.delete(`/v2/bookings/${uid}`, { data: { seatUid: activeSeatUid } });
Defensive patterns

Strategy: validation

Validate before calling

const booking = await client.get(`/v2/bookings/${uid}`);
const seatActive = booking.seats?.some(s => s.seatUid === body.seatUid);
if (!seatActive) throw new Error('seatUid is not active');

Type guard

function isSeatActive(seatUid: string, seats: { seatUid: string; cancelled?: boolean }[]): boolean {
  return seats.some(s => s.seatUid === seatUid && !s.cancelled);
}

Try / catch

try { await client.delete(`/v2/bookings/${uid}`, { data: { seatUid } }); }
catch (e) {
  if (e.status === 400 && /does not exist or has already been cancelled/i.test(e.message)) { /* seat already gone; treat as success */ }
  else throw e;
}

Prevention

When it happens

Trigger: Cancelling a single seat with body.seatUid set, where the seatUid does not exist or has already been cancelled (seats are deleted on cancel).

Common situations: Double-cancelling a seat; passing the booking uid as seatUid; seatUid from a different booking or environment.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/1caaf0a51dba4d3f. Report an issue: GitHub.