calcom/cal.diy · error · BadRequestException

Attempting to book a meeting in the past.

Error message

Attempting to book a meeting in the past.

What it means

Thrown by handleBookingError when the booking engine's error.message is exactly 'Attempting to book a meeting in the past.' BadRequestException (HTTP 400). The requested start time is before now (clock skew, stale slot, or a client bug sending an unadjusted past timestamp).

Source

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

    }
    throw new NotFoundException(`Event type with id ${body.eventTypeId} not found.`);
  }

  handleBookingError(error: unknown, bookingTeamEventType: boolean): never {
    const hostsUnavaile = "One of the hosts either already has booking at this time or is not available";

    if (error instanceof Error) {
      if (error.message === "no_available_users_found_error") {
        if (bookingTeamEventType) {
          throw new BadRequestException(hostsUnavaile);
        }
        throw new BadRequestException("User either already has booking at this time or is not available");
      } else if (error.message === "booking_time_out_of_bounds_error") {
        throw new BadRequestException(
          `The event type can't be booked at the "start" time provided. This could be because it's too soon (violating the minimum booking notice) or too far in the future (outside the event's scheduling window). Try fetching available slots first using the GET /v2/slots endpoint and then make a booking with "start" time equal to one of the available slots.`
        );
      } else if (error.message === "Attempting to book a meeting in the past.") {
        throw new BadRequestException("Attempting to book a meeting in the past.");
      } else if (error.message === "hosts_unavailable_for_booking") {
        throw new BadRequestException(hostsUnavaile);
      } else if (error.message === "booker_limit_exceeded_error") {
        throw new BadRequestException(
          "Attendee with this email can't book because the maximum number of active bookings has been reached."
        );
      } else if (error.message === "booker_limit_exceeded_error_reschedule") {
        const errorData =
          "data" in error ? (error.data as { rescheduleUid: string }) : { rescheduleUid: undefined };
        let message =
          "Attendee with this email can't book because the maximum number of active bookings has been reached.";
        if (errorData?.rescheduleUid) {
          message += ` You can reschedule your existing booking (${errorData.rescheduleUid}) to a new timeslot instead.`;
        }
        throw new BadRequestException(message);
      }
    }
    throw error;

View on GitHub (pinned to 176037d0af)

Solutions

  1. Refresh the slot list immediately before booking if more than a few minutes have passed.
  2. Synchronize the client clock (NTP) and validate start > now() before sending.
  3. Discard and re-fetch on retry rather than reusing the original body.
  4. Account for DST transitions when computing start times.

Example fix

// before
start = cachedSlot.start  // fetched hours ago, now in the past

// after
if (dayjs(start).isBefore(dayjs())) {
  const slots = await api.get(`/v2/slots?...`);
  start = slots.data.slots[0].start;
}
Defensive patterns

Strategy: validation

Validate before calling

const startMs = new Date(body.start).getTime();
if (!Number.isFinite(startMs) || startMs <= Date.now()) throw new Error('start must be in the future');

Type guard

const isFutureStart = (start: string): boolean =>
  Number.isFinite(new Date(start).getTime()) && new Date(start).getTime() > Date.now();

Try / catch

try { await api.post('/v2/bookings', body); }
catch (e) {
  if (e.response?.status === 400 && /in the past/.test(e.response.data.message)) {
    /* refresh slot list, pick a future start, retry */
  } else throw e;
}

Prevention

When it happens

Trigger: Posting a start time that has already elapsed — a slot fetched long ago, a clock skewed client, a retry of a request queued overnight, or a hardcoded timestamp. The engine rejects any start < now.

Common situations: Long latency between GET /v2/slots and POST /v2/bookings letting the slot slip into the past; client clock behind server time; retry of a queued request the next day; daylight-saving transition producing a past-equivalent timestamp.

Related errors


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