calcom/cal.diy · error · NotFoundException

Booking with uid=${bookingUid} was not found in the database

Error message

Booking with uid=${bookingUid} was not found in the database

What it means

Thrown by shouldRescheduleIndividualSeat when getByUidWithUserIdAndSeatsReferencesCount returns null for the provided bookingUid. This guard runs during reschedule routing to decide whether a seat-level reschedule applies. NotFoundException (HTTP 404).

Source

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

    }
    if (booking.status === "CANCELLED" && booking.rescheduled) {
      const rescheduledTo = await this.bookingsRepository.getByFromReschedule(bookingUid);
      throw new BadRequestException(
        `Can't reschedule booking with uid=${bookingUid} because it has been cancelled and rescheduled already to booking with uid=${rescheduledTo?.uid}. You probably want to reschedule ${rescheduledTo?.uid} instead by passing it within the request URL.`
      );
    }
    return booking;
  }

  async shouldRescheduleIndividualSeat(
    bookingUid: string,
    isIndividualSeatReschedule: boolean,
    authUser: AuthOptionalUser
  ) {
    const booking = await this.bookingsRepository.getByUidWithUserIdAndSeatsReferencesCount(bookingUid);

    if (!booking) {
      throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
    }

    const hasSeatsPresent = booking.seatsReferences.length > 0;

    if (!hasSeatsPresent) return false;

    return await this.isIndividualSeatOrOrgAdminReschedule(
      isIndividualSeatReschedule,
      booking.userId,
      authUser?.id
    );
  }

  async isIndividualSeatOrOrgAdminReschedule(
    isIndividualSeatReschedule: boolean,
    bookingUserId: number | null,
    authUserId?: number | null
  ) {

View on GitHub (pinned to 176037d0af)

Solutions

  1. Validate the bookingUid format and existence via GET /v2/bookings/:uid before rescheduling.
  2. Ensure the correct uid (booking, not seat) is passed to the reschedule endpoint.
  3. Use the uid returned by the original booking creation response.

Example fix

// before
await client.post(`/v2/bookings/${maybeSeatUid}/reschedule`, body);
// after
const booking = await client.get(`/v2/bookings/${uid}`);
await client.post(`/v2/bookings/${booking.uid}/reschedule`, body);
Defensive patterns

Strategy: validation

Validate before calling

const b = await client.get(`/v2/bookings/${uid}`);
if (!b) throw new Error('Booking not found; cannot reschedule');

Type guard

function isExistingBooking<T>(b: T | null): b is T { return b !== null; }

Try / catch

try { await client.post(`/v2/bookings/${uid}/reschedule`, body); }
catch (e) {
  if (e.status === 404 && /not found in the database/.test(e.message)) { /* surface 'booking missing' to user */ }
  else throw e;
}

Prevention

When it happens

Trigger: A reschedule request whose bookingUid does not exist in the database when the service checks for seat references and ownership routing.

Common situations: Typo in uid; booking deleted; using a seatUid where a bookingUid is expected; environment mismatch.

Related errors


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