calcom/cal.diy · error · BadRequestException

Booking location with type ${(location as BookingInputLocati

Error message

Booking location with type ${(location as BookingInputLocation_2024_08_13).type} not valid.

What it means

Thrown at the bottom of transformLocation when the location object's type does not match any handled branch (address, link, integration, phone, attendeeAddress, attendeePhone, attendeeDefined, organizersDefaultApp, attendeeDefined). BadRequestException (HTTP 400). It is the defensive fallthrough after the type union check.

Source

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

        optionValue: "",
      };
    }

    if (location.type === "attendeePhone") {
      return {
        value: "phone",
        optionValue: location.phone,
      };
    }

    if (location.type === "attendeeDefined") {
      return {
        value: "somewhereElse",
        optionValue: location.location,
      };
    }

    throw new BadRequestException(
      `Booking location with type ${(location as BookingInputLocation_2024_08_13).type} not valid.`
    );
  }

  private isBookingLocationWithEventTypeLocations(
    inputBookingLocation: undefined | string | BookingInputLocation_2024_08_13,
    dbEventType: EventType
  ) {
    if (!inputBookingLocation || typeof inputBookingLocation === "string") {
      // note(Lauris): for backwards compatibility because we had string locations before so let them pass.
      return true;
    }

    const eventTypeLocations = this.outputEventTypesService.transformLocations(dbEventType.locations);
    const allowedLocationTypes = eventTypeLocations.map((location) => location.type);

    const isAllowed = allowedLocationTypes.includes(inputBookingLocation.type);
    if (!isAllowed) {

View on GitHub (pinned to 176037d0af)

Solutions

  1. Use one of the documented inputLocations values: address, link, integration, phone, attendeePhone, attendeeAddress, attendeeDefined, organizersDefaultApp.
  2. Verify the type matches the API version deployed on the server.
  3. Do not send internal Cal type names (inPerson, userPhone, somewhereElse) — those are output-only.
  4. Run the BookingInputLocationValidator on the payload before sending to catch typos early.

Example fix

// before
location: { type: 'inPerson', address: '123 St' }  // internal name

// after
location: { type: 'address' }
Defensive patterns

Strategy: type-guard

Validate before calling

import { inputLocations } from '@calcom/platform-types/bookings/2024-08-13/inputs/location.input';
if (typeof body.location === 'object' && !inputLocations.includes(body.location.type)) {
  throw new Error(`location.type must be one of ${inputLocations.join(', ')}`);
}

Type guard

import { inputLocations } from '@calcom/platform-types/bookings/2024-08-13/inputs/location.input';
const isValidLocationType = (t: string): t is typeof inputLocations[number] =>
  (inputLocations as readonly string[]).includes(t);

Try / catch

try { await api.post('/v2/bookings', body); }
catch (e) {
  if (e.response?.status === 400 && /location with type.*not valid/i.test(e.response.data.message)) {
    /* fix the type to one of inputLocations and retry */
  } else throw e;
}

Prevention

When it happens

Trigger: POST /v2/bookings with body.location = { type: <unknown value>, ... } where type is not one of the eight supported inputLocations. Normally the BookingInputLocationValidator_2024_08_13 class-validator rejects unknown types first with a different message; this fires only if validation was bypassed or a new type was introduced in the union without a transformLocation branch.

Common situations: Typos in the type field ('adress', 'integrations'); using internal type names ('inPerson', 'somewhereElse') instead of API type names ('address', 'attendeeDefined'); version skew where a newer client sends a type the deployed server does not know; bypassing the DTO validation layer.

Related errors


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