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
- Always send either duration (minutes) or eventTypeId in the slots query.
- If you only have an event type slug, resolve it to an id first via the event-types endpoint.
- 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
- Always include either duration or eventTypeId in the slots query.
- Resolve event-type slugs to ids before calling slots.
- Maintainer: throw BadRequestException instead of plain Error for a proper 400.
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
- Event type not found
- Invalid time range given - check the 'startTime' and 'endTim
- ${error.message as TRPCErrorCode}
- Invalid slot format. Must be either 'range' or 'time'
- Event Type not found
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/d230d3e01b5b5103.
Report an issue: GitHub.