calcom/cal.diy · error · NotFoundException

Reassigned booking with uid=${bookingUid} was not found in t

Error message

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

What it means

Thrown near the end of reassignBooking after roundRobinReassignment succeeds but the follow-up getByUidWithUser(bookingUid) returns null. It is a NestJS NotFoundException (HTTP 404) indicating the booking vanished between mutation and re-fetch. This signals a data-integrity or concurrency problem rather than normal usage.

Source

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

        platformClientParams,
        reassignedById: reassignedByUser.id,
        actionSource: "API_V2",
        reassignedByUuid: reassignedByUser.uuid,
      });
    } catch (error) {
      if (error instanceof Error) {
        if (error.message === "no_available_users_found_error") {
          throw new BadRequestException(
            "Can't reassign the booking because no other host is available at that time."
          );
        }
      }
      throw error;
    }

    const reassigned = await this.bookingsRepository.getByUidWithUser(bookingUid);
    if (!reassigned) {
      throw new NotFoundException(`Reassigned booking with uid=${bookingUid} was not found in the database`);
    }

    return this.outputService.getOutputReassignedBooking(reassigned);
  }

  async reassignBookingToUser(
    bookingUid: string,
    newUserId: number,
    reassignedByUser: ApiAuthGuardUser,
    body: ReassignToUserBookingInput_2024_08_13
  ) {
    const booking = await this.bookingsRepository.getByUidWithEventType(bookingUid);
    if (!booking) {
      throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
    }
    if (!booking.eventType) {
      throw new BadRequestException(
        `Event type with id=${booking.eventTypeId} was not found in the database`

View on GitHub (pinned to 176037d0af)

Solutions

  1. Retry the GET /v2/bookings/{uid} after a short delay to rule out transient read lag.
  2. Confirm the booking still exists in the database (it may have been deleted concurrently).
  3. Check for background jobs or cascades that delete bookings around reassignment.
  4. If reproducible, escalate to backend/DBA to inspect the reassignment transaction boundaries.

Example fix

// before
const result = await apiClient.post(`/v2/bookings/${uid}/reassign`);

// after
const reassigned = await withRetry(
  () => apiClient.get(`/v2/bookings/${uid}`).then(r => r.data),
  { retries: 3, delayMs: 200 }
);
if (!reassigned) throw new Error(`Booking ${uid} disappeared after reassign - possible concurrent delete`);
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight existence check (does not prevent the race but cheap to do)
const exists = await apiClient.get(`/v2/bookings/${uid}`).then(() => true).catch(e => e.response?.status !== 404);
if (!exists) throw new Error(`Booking ${uid} missing before reassign`);

Type guard

function isPostReassignMissing(err: unknown): boolean {
  return typeof err === 'object' && err !== null &&
    (err as any).response?.status === 404 &&
    /Reassigned booking.*not found/i.test((err as any).response?.data?.message ?? '');
}

Try / catch

try {
  await apiClient.post(`/v2/bookings/${uid}/reassign`);
} catch (err) {
  if (isPostReassignMissing(err)) {
    // transient read failure or concurrent delete - re-read with backoff
    await withRetry(() => apiClient.get(`/v2/bookings/${uid}`), { retries: 3, delayMs: 250 });
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: The booking being deleted (hard delete or cascade) by another process in the window between the reassignment commit and the re-fetch; a transaction rollback that left the reassignment partially applied; a uid casing/mismatch bug in the repository query.

Common situations: Concurrent cleanup jobs that purge old/cancelled bookings; manual DB intervention during testing; replication lag where the read goes to a stale replica; extremely rare race conditions under load.

Related errors


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