{"record":{"id":"03c7f444d8c288e8","repo":"calcom/cal.diy","slug":"invalid-seatuid-this-seat-does-not-belong-to-this","errorCode":null,"errorMessage":"Invalid seatUid: this seat does not belong to this booking.","messagePattern":"Invalid seatUid: this seat does not belong to this booking\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts","lineNumber":910,"sourceCode":"  }\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,\n      platformRescheduleUrl: bookingRequest.platformRescheduleUrl,\n      platformBookingUrl: bookingRequest.platformBookingUrl,\n    });\n\n    if (\"cancelSubsequentBookings\" in body && body.cancelSubsequentBookings) {\n      return this.getAllRecurringBookingsByIndividualUid(bookingUid, authUser);","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts#L892-L928","documentation":"Thrown by cancelBooking when the seated-cancellation body resolves a seat, but the seat's parent booking uid does not match the bookingUid in the request path/body. BadRequestException (HTTP 400). This prevents cancelling a seat under the wrong booking.","triggerScenarios":"Cancelling a seat where body.seatUid belongs to booking A but the request targets booking B (mismatched path uid and seat uid).","commonSituations":"Stale pairing of bookingUid and seatUid in client state; copy-paste error; seat reused across bookings (data integrity issue).","solutions":["Always pair the seatUid with the bookingUid obtained from the same booking detail response.","Fetch the booking and read seat.booking.uid to align the two values before cancelling.","Validate seatUid ownership client-side: assert seat belongs to the booking in the URL."],"exampleFix":"// before\nawait client.delete(`/v2/bookings/${bookingA}`, { data: { seatUid: seatFromBookingB } });\n// after\nconst seat = booking.seats.find(s => s.seatUid === targetSeatUid);\nawait client.delete(`/v2/bookings/${seat.bookingUid}`, { data: { seatUid: seat.seatUid } });","handlingStrategy":"validation","validationCode":"const booking = await client.get(`/v2/bookings/${uid}`);\nconst seat = booking.seats?.find(s => s.seatUid === body.seatUid);\nif (!seat || seat.bookingUid !== uid) throw new Error('seatUid does not belong to this booking');","typeGuard":"function seatBelongsToBooking(seat: { bookingUid: string } | undefined, uid: string): boolean {\n  return !!seat && seat.bookingUid === uid;\n}","tryCatchPattern":"try { await client.delete(`/v2/bookings/${uid}`, { data: { seatUid } }); }\ncatch (e) {\n  if (e.status === 400 && /does not belong to this booking/i.test(e.message)) { /* refetch seats, correct pairing */ }\n  else throw e;\n}","preventionTips":["Always pair seatUid with its parent booking uid","Fetch the booking to derive the correct seat pairing","Avoid mixing seat uids across bookings in client state"],"tags":["api-v2","bookings","seats","cancel","validation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}