{"record":{"id":"d230d3e01b5b5103","repo":"calcom/cal.diy","slug":"duration-or-eventtypeid-is-required","errorCode":null,"errorMessage":"duration or eventTypeId is required","messagePattern":"duration or eventTypeId is required","errorType":"http","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots-output.service.ts","lineNumber":104,"sourceCode":"    }, {});\n\n    return { slots };\n  }\n\n  private async getDuration(duration?: number, eventTypeId?: number): Promise<number> {\n    if (duration) {\n      return duration;\n    }\n\n    if (eventTypeId) {\n      const eventType = await this.eventTypesRepository.getEventTypeWithDuration(eventTypeId);\n      if (!eventType) {\n        throw new Error(\"Event type not found\");\n      }\n      return eventType.length;\n    }\n\n    throw new Error(\"duration or eventTypeId is required\");\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":107,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots-output.service.ts#L86-L107","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — query missing both\napi.get('/slots/2024-04-15', { startTime, endTime }); // 500\n// after — provide duration\napi.get('/slots/2024-04-15', { startTime, endTime, duration: 30 });\n// or\napi.get('/slots/2024-04-15', { startTime, endTime, eventTypeId: 42 });","handlingStrategy":"validation","validationCode":"function buildSlotsDurationQuery(duration?: number, eventTypeId?: number) {\n  if (!duration && !eventTypeId)\n    throw new Error('Provide either duration (minutes) or eventTypeId');\n  return { duration, eventTypeId };\n}","typeGuard":"const hasDurationSource = (duration?: number, eventTypeId?: number): boolean =>\n  Boolean(duration) || Boolean(eventTypeId);","tryCatchPattern":null,"preventionTips":["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."],"tags":["slots","missing-argument","wrong-exception-type","nestjs","bug"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}