calcom/cal.diy · error · NotFoundException

No user found for booking with uid=${bookingUid}

Error message

No user found for booking with uid=${bookingUid}

What it means

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.

Source

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

          await this.calendarSyncService.syncCalendarEvent(existingBooking.id, locationValue);
        }
      }
      return await this.updateLocation(existingBooking, location, user);
    }

    return this.bookingsService.getBooking(existingBooking.uid, user);
  }

  private async updateLocation(
    existingBooking: BookingForLocationUpdate,
    inputLocation: UpdateBookingInputLocation_2024_08_13,
    user: ApiAuthGuardUser
  ): Promise<BookingLocationResponse> {
    const bookingUid = existingBooking.uid;
    const oldLocation = existingBooking.location;

    if (!existingBooking.userId) {
      throw new NotFoundException(`No user found for booking with uid=${bookingUid}`);
    }

    if (!existingBooking.eventTypeId) {
      throw new NotFoundException(`No event type found for booking with uid=${bookingUid}`);
    }

    const existingBookingHost = await this.usersRepository.findById(existingBooking.userId);

    if (!existingBookingHost) {
      throw new NotFoundException(`No user found for booking with uid=${bookingUid}`);
    }

    if (inputLocation.type === "integration") {
      return this.integrationService.handleIntegrationLocationUpdate(
        existingBooking,
        inputLocation,
        user,
        existingBookingHost

View on GitHub (pinned to 176037d0af)

Solutions

  1. Set booking.userId to a valid user before attempting the location update.
  2. Avoid PATCHing location on bookings that lack an owner; recreate them through the normal flow.
  3. Backfill null userIds in the database for affected bookings.
Defensive patterns

Strategy: type-guard

Validate before calling

// Before PATCHing location, confirm the booking has an owner userId.
const booking = await api.get(`/v2/bookings/${uid}`);
if (!booking.userId) throw new Error(`Booking ${uid} has no owner user; cannot update location`);

Type guard

function bookingHasOwnerId(b: { userId: number | null } | null | undefined): b is { userId: number } {
  return !!b && typeof b.userId === 'number' && b.userId > 0;
}

Try / catch

try {
  await api.patch(`/v2/bookings/${uid}/location`, payload);
} catch (err) {
  if (err.status === 404 && /No user found/.test(err.message)) {
    // booking is orphaned (userId null): reassign owner or skip
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Legacy/migrated bookings with null userId; bookings created by system/anonymous flows; data corruption where userId was cleared.

Related errors


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