calcom/cal.diy · error · Error

duration or eventTypeId is required

Error message

duration or eventTypeId is required

What it means

A plain Error thrown by getDuration() when neither duration nor eventTypeId is supplied. The slot formatting pipeline needs a slot length to split the available window; with no duration and no event type to derive one from, it cannot proceed. Like error 156 this is a raw Error that bubbles as HTTP 500 rather than a 400, which is likely a defect.

Source

Thrown at apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots-output.service.ts:104

    }, {});

    return { slots };
  }

  private async getDuration(duration?: number, eventTypeId?: number): Promise<number> {
    if (duration) {
      return duration;
    }

    if (eventTypeId) {
      const eventType = await this.eventTypesRepository.getEventTypeWithDuration(eventTypeId);
      if (!eventType) {
        throw new Error("Event type not found");
      }
      return eventType.length;
    }

    throw new Error("duration or eventTypeId is required");
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Always send either duration (minutes) or eventTypeId in the slots query.
  2. If you only have an event type slug, resolve it to an id first via the event-types endpoint.
  3. Maintainer fix: throw a BadRequestException instead of Error so the client sees a 400 with a clear message.

Example fix

// before — query missing both
api.get('/slots/2024-04-15', { startTime, endTime }); // 500
// after — provide duration
api.get('/slots/2024-04-15', { startTime, endTime, duration: 30 });
// or
api.get('/slots/2024-04-15', { startTime, endTime, eventTypeId: 42 });
Defensive patterns

Strategy: validation

Validate before calling

function buildSlotsDurationQuery(duration?: number, eventTypeId?: number) {
  if (!duration && !eventTypeId)
    throw new Error('Provide either duration (minutes) or eventTypeId');
  return { duration, eventTypeId };
}

Type guard

const hasDurationSource = (duration?: number, eventTypeId?: number): boolean =>
  Boolean(duration) || Boolean(eventTypeId);

Prevention

When it happens

Trigger: GET /v2/slots/2024-04-15 with neither a duration query param nor an eventTypeId (or eventTypeId explicitly null/0). The caller must provide one of the two for the service to compute slot length.

Common situations: A client that previously sent eventTypeId dropping it after a refactor; an integration querying slots generically without an event type; a malformed query string where duration fails to parse to a number.

Related errors


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