calcom/cal.diy · error · BadRequestException

Provided 'lengthInMinutes' is not one of the possible length

Error message

Provided 'lengthInMinutes' is not one of the possible lengths for the event type. The possible lengths are: ${eventTypeMetadata?.multipleDuration?.join(", ")}

What it means

Thrown by validateBookingLengthInMinutes when lengthInMinutes is provided, the event type DOES have multipleDuration, but the supplied value is not in that list. BadRequestException (HTTP 400). The message enumerates the allowed values (joined by ', ') so the client can correct the value.

Source

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

      teamMemberEmail: routing.teamMemberEmail,
      skipContactOwner: routing.skipContactOwner,
      crmAppSlug: routing.crmAppSlug,
      crmOwnerRecordType: routing.crmOwnerRecordType,
    };
  }

  validateBookingLengthInMinutes(inputBooking: CreateBookingInput_2024_08_13, eventType: EventType) {
    const eventTypeMetadata = EventTypeMetaDataSchema.parse(eventType.metadata);
    if (inputBooking.lengthInMinutes && !eventTypeMetadata?.multipleDuration) {
      throw new BadRequestException(
        "Can't specify 'lengthInMinutes' because event type does not have multiple possible lengths. Please, remove the 'lengthInMinutes' field from the request."
      );
    }
    if (
      inputBooking.lengthInMinutes &&
      !eventTypeMetadata?.multipleDuration?.includes(inputBooking.lengthInMinutes)
    ) {
      throw new BadRequestException(
        `Provided 'lengthInMinutes' is not one of the possible lengths for the event type. The possible lengths are: ${eventTypeMetadata?.multipleDuration?.join(
          ", "
        )}`
      );
    }
  }

  async createRecurringBookingRequest(
    request: Request,
    body: CreateRecurringBookingInput_2024_08_13,
    eventType: EventTypeWithOwnerAndTeam
  ): Promise<BookingRequest> {
    const oAuthClientParams = await this.platformBookingsService.getOAuthClientParamsForEventType(eventType);
    // note(Lauris): update to this.transformInputCreate when rescheduling is implemented
    const bodyTransformed = await this.transformInputCreateRecurringBooking(
      body,
      eventType,
      oAuthClientParams?.platformClientId

View on GitHub (pinned to 176037d0af)

Solutions

  1. Read the allowed durations from GET /v2/event-types/{id} -> metadata.multipleDuration and pick one of those exact values.
  2. Refresh cached event-type metadata before constructing the booking payload.
  3. If none of the listed durations fit, update the event type's multipleDuration list to include the desired value.
  4. Validate lengthInMinutes against the fetched list client-side before POSTing.

Example fix

// before
body: { eventTypeId, lengthInMinutes: 45, ... }  // allowed: [15,30,60]

// after
const et = await api.get(`/v2/event-types/${eventTypeId}`);
const allowed = et.data.metadata.multipleDuration;
body.lengthInMinutes = allowed.includes(45) ? 45 : allowed[0];
Defensive patterns

Strategy: validation

Validate before calling

const et = await api.get(`/v2/event-types/${eventTypeId}`);
const allowed = et.data.metadata?.multipleDuration ?? [];
if (body.lengthInMinutes && !allowed.includes(body.lengthInMinutes)) {
  body.lengthInMinutes = allowed[0];
}

Type guard

const isValidDuration = (length: number, et: { metadata?: { multipleDuration?: number[] } }): boolean =>
  Array.isArray(et.metadata?.multipleDuration) && (et.metadata?.multipleDuration?.includes(length) ?? false);

Try / catch

try { await api.post('/v2/bookings', body); }
catch (e) {
  if (e.response?.status === 400 && /not one of the possible lengths/.test(e.response.data.message)) {
    const m = e.response.data.message.match(/are: (.*)$/);
    body.lengthInMinutes = Number(m[1].split(',')[0]);
    await api.post('/v2/bookings', body);
  } else throw e;
}

Prevention

When it happens

Trigger: POST /v2/bookings against a multi-duration event type with a lengthInMinutes that is not one of metadata.multipleDuration (e.g. sending 45 when allowed durations are [15, 30, 60]). The validator checks Array.includes and rejects.

Common situations: Hard-coded duration in the client that does not match the event type's configured set; event type's multipleDuration list was edited; mismatched units (minutes vs hours); stale cached event-type metadata.

Related errors


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