calcom/cal.diy · error · BadRequestException
Event type with id=${booking.eventTypeId} was not found in t
Error message
Event type with id=${booking.eventTypeId} was not found in the database What it means
Thrown by BookingsService.reassignBooking when the booking row loaded via getByUidWithEventType exists but its eventType relation is null (the eventTypeId foreign key points to a missing/deleted event type). It is a NestJS BadRequestException (HTTP 400) because reassignment logic depends on event-type metadata (hosts, scheduling) that cannot be reconstructed. The check is `if (!booking.eventType)` immediately after the booking lookup, so a null relation trips it even when eventTypeId is set.
Source
Thrown at apps/api/v2/src/platform/bookings/2024-08-13/services/bookings.service.ts:1000
if (!booking) {
throw new Error(`Booking with uid=${bookingUid} was not found in the database`);
}
const isRecurring = !!booking.recurringEventId;
if (isRecurring) {
return this.outputService.getOutputRecurringBooking(booking);
}
return this.outputService.getOutputBooking(booking);
}
async reassignBooking(bookingUid: string, reassignedByUser: ApiAuthGuardUser) {
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`
);
}
const isAllowed = await this.eventTypeAccessService.userIsEventTypeAdminOrOwner(
reassignedByUser,
booking.eventType
);
if (!isAllowed) {
throw new ForbiddenException(BOOKING_REASSIGN_PERMISSION_ERROR);
}
const platformClientParams = booking.eventTypeId
? await this.platformBookingsService.getOAuthClientParams(booking.eventTypeId)
: undefined;
const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;View on GitHub (pinned to 176037d0af)
Solutions
- Verify the booking and its event type with GET /v2/bookings/{bookingUid} before calling reassign, and confirm the response includes a non-null eventTypeId/eventType.
- If the event type was deleted, restore it or recreate it with the same id, then retry the reassign call.
- If the data is inconsistent, ask a DB admin to reconcile the booking.eventTypeId or remove the orphaned booking.
- Guard the caller so it never attempts reassign on bookings whose eventType is missing.
Example fix
// before
await apiClient.post(`/v2/bookings/${uid}/reassign`);
// after
const booking = await apiClient.get(`/v2/bookings/${uid}`).then(r => r.data);
if (!booking.eventTypeId || !booking.eventType) {
throw new Error(`Cannot reassign booking ${uid}: it has no event type (was it deleted?)`);
}
await apiClient.post(`/v2/bookings/${uid}/reassign`); Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: ensure the booking has a resolvable event type before reassign
const booking = await apiClient.get(`/v2/bookings/${bookingUid}`).then(r => r.data);
if (!booking) throw new Error(`Booking ${bookingUid} not found`);
if (!booking.eventTypeId || !booking.eventType) {
throw new Error(`Booking ${bookingUid} has no event type - reassign is not possible`);
} Type guard
function hasEventType(b: { eventTypeId?: number | null; eventType?: unknown | null }): b is { eventTypeId: number; eventType: NonNullable<typeof b.eventType> } {
return b.eventTypeId != null && b.eventType != null;
} Try / catch
try {
await apiClient.post(`/v2/bookings/${uid}/reassign`);
} catch (err) {
if (err.response?.status === 400 && /event type.*not found/i.test(err.response?.data?.message ?? '')) {
throw new ReassignSkippedError(`Orphaned booking ${uid} - event type missing`);
}
throw err;
} Prevention
- Never hard-delete event types that still have bookings; soft-delete or audit first.
- Validate booking.eventType presence in any workflow that selects reassign candidates.
- Run a periodic job to detect orphaned bookings (eventTypeId set, EventType missing).
When it happens
Trigger: POST to the reassign-booking endpoint with a bookingUid whose event type record was deleted or whose eventType relation was not selected by the repository query; a booking created by an integration that never wrote a matching EventType row.
Common situations: Orphaned bookings left after an event type was hard-deleted; staging/test databases with partial imports where bookings exist without their event types; multi-org setups where the event type lives in a different org scope than the booking.
Related errors
- Reassigned booking with uid=${bookingUid} was not found in t
- Booking with uid ${uid} not found
- Event type with uid ${uid} not found
- No event type found for booking with uid=${bookingUid}
- You do not have permission to reassign this booking
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/dde69f4129aef334.
Report an issue: GitHub.