{"record":{"id":"cd80e1dd14a6d320","repo":"calcom/cal.diy","slug":"no-user-found-for-booking-with-uid-bookinguid","errorCode":null,"errorMessage":"No user found for booking with uid=${bookingUid}","messagePattern":"No user found for booking with uid=(.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/booking-location.service.ts","lineNumber":92,"sourceCode":"          await this.calendarSyncService.syncCalendarEvent(existingBooking.id, locationValue);\n        }\n      }\n      return await this.updateLocation(existingBooking, location, user);\n    }\n\n    return this.bookingsService.getBooking(existingBooking.uid, user);\n  }\n\n  private async updateLocation(\n    existingBooking: BookingForLocationUpdate,\n    inputLocation: UpdateBookingInputLocation_2024_08_13,\n    user: ApiAuthGuardUser\n  ): Promise<BookingLocationResponse> {\n    const bookingUid = existingBooking.uid;\n    const oldLocation = existingBooking.location;\n\n    if (!existingBooking.userId) {\n      throw new NotFoundException(`No user found for booking with uid=${bookingUid}`);\n    }\n\n    if (!existingBooking.eventTypeId) {\n      throw new NotFoundException(`No event type found for booking with uid=${bookingUid}`);\n    }\n\n    const existingBookingHost = await this.usersRepository.findById(existingBooking.userId);\n\n    if (!existingBookingHost) {\n      throw new NotFoundException(`No user found for booking with uid=${bookingUid}`);\n    }\n\n    if (inputLocation.type === \"integration\") {\n      return this.integrationService.handleIntegrationLocationUpdate(\n        existingBooking,\n        inputLocation,\n        user,\n        existingBookingHost","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/booking-location.service.ts#L74-L110","documentation":"Thrown early in updateLocation when existingBooking.userId is falsy. The booking row exists but has no owner user assigned, and the location update flow (especially the integration branch) needs a host user. Distinct from error 270 which fires when userId is set but the user record is missing.","triggerScenarios":"PATCH booking location on a booking whose userId column is null. The earlier UID lookup succeeded (so error 266 didn't fire), but this booking was never assigned an owner.","commonSituations":"Legacy/migrated bookings with null userId; bookings created by system/anonymous flows; data corruption where userId was cleared.","solutions":["Set booking.userId to a valid user before attempting the location update.","Avoid PATCHing location on bookings that lack an owner; recreate them through the normal flow.","Backfill null userIds in the database for affected bookings."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Before PATCHing location, confirm the booking has an owner userId.\nconst booking = await api.get(`/v2/bookings/${uid}`);\nif (!booking.userId) throw new Error(`Booking ${uid} has no owner user; cannot update location`);","typeGuard":"function bookingHasOwnerId(b: { userId: number | null } | null | undefined): b is { userId: number } {\n  return !!b && typeof b.userId === 'number' && b.userId > 0;\n}","tryCatchPattern":"try {\n  await api.patch(`/v2/bookings/${uid}/location`, payload);\n} catch (err) {\n  if (err.status === 404 && /No user found/.test(err.message)) {\n    // booking is orphaned (userId null): reassign owner or skip\n  }\n  throw err;\n}","preventionTips":["Never create bookings without an owner user.","Backfill null userIds in migrations.","Guard the PATCH path by checking booking.userId before calling."],"tags":["booking","data-integrity","user","location"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}