{"record":{"id":"1caaf0a51dba4d3f","repo":"calcom/cal.diy","slug":"invalid-seatuid-this-seat-does-not-exist-or-has-a","errorCode":null,"errorMessage":"Invalid seatUid: this seat does not exist or has already been cancelled.","messagePattern":"Invalid seatUid: this seat does not exist or has already been cancelled\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts","lineNumber":904,"sourceCode":"\n    return isOrgAdmin;\n  }\n\n  isRescheduleSeatedBody(body: RescheduleBookingInput): body is RescheduleSeatedBookingInput_2024_08_13 {\n    return \"seatUid\" in body;\n  }\n\n  async cancelBooking(\n    request: Request,\n    bookingUid: string,\n    body: CancelBookingInput,\n    authUser: AuthOptionalUser\n  ) {\n    if (this.inputService.isCancelSeatedBody(body)) {\n      const seat = await this.bookingSeatRepository.getByReferenceUid(body.seatUid);\n\n      if (!seat) {\n        throw new BadRequestException(\n          \"Invalid seatUid: this seat does not exist or has already been cancelled.\"\n        );\n      }\n\n      if (seat && bookingUid !== seat.booking.uid) {\n        throw new BadRequestException(\"Invalid seatUid: this seat does not belong to this booking.\");\n      }\n    }\n\n    const bookingRequest = await this.inputService.createCancelBookingRequest(request, bookingUid, body);\n    const res = await handleCancelBooking({\n      bookingData: bookingRequest.body,\n      userId: bookingRequest.userId,\n      userUuid: authUser?.uuid,\n      actionSource: \"API_V2\",\n      arePlatformEmailsEnabled: bookingRequest.arePlatformEmailsEnabled,\n      platformClientId: bookingRequest.platformClientId,\n      platformCancelUrl: bookingRequest.platformCancelUrl,","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts#L886-L922","documentation":"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).","triggerScenarios":"Cancelling a single seat with body.seatUid set, where the seatUid does not exist or has already been cancelled (seats are deleted on cancel).","commonSituations":"Double-cancelling a seat; passing the booking uid as seatUid; seatUid from a different booking or environment.","solutions":["Verify the seatUid is active by fetching the parent booking and inspecting its seats before cancelling.","Guard against double-cancel: track local seat state and skip if already cancelled.","Ensure the value is the seat reference uid, not the booking uid."],"exampleFix":"// before\nawait client.delete(`/v2/bookings/${uid}`, { data: { seatUid: bookingUid } });\n// after\nawait client.delete(`/v2/bookings/${uid}`, { data: { seatUid: activeSeatUid } });","handlingStrategy":"validation","validationCode":"const booking = await client.get(`/v2/bookings/${uid}`);\nconst seatActive = booking.seats?.some(s => s.seatUid === body.seatUid);\nif (!seatActive) throw new Error('seatUid is not active');","typeGuard":"function isSeatActive(seatUid: string, seats: { seatUid: string; cancelled?: boolean }[]): boolean {\n  return seats.some(s => s.seatUid === seatUid && !s.cancelled);\n}","tryCatchPattern":"try { await client.delete(`/v2/bookings/${uid}`, { data: { seatUid } }); }\ncatch (e) {\n  if (e.status === 400 && /does not exist or has already been cancelled/i.test(e.message)) { /* seat already gone; treat as success */ }\n  else throw e;\n}","preventionTips":["Track local seat state to avoid double-cancel","Fetch booking seats before cancelling","Treat 'already cancelled' as idempotent success"],"tags":["api-v2","bookings","seats","cancel","validation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}