{"record":{"id":"905e205df8c28ddb","repo":"calcom/cal.diy","slug":"event-type-not-found","errorCode":null,"errorMessage":"Event type not found","messagePattern":"Event type not found","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":99,"sourceCode":"          ...(slot.attendees ? { attendees: slot.attendees } : {}),\n          ...(slot.bookingUid ? { bookingUid: slot.bookingUid } : {}),\n        };\n      });\n      return acc;\n    }, {});\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":81,"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#L81-L107","documentation":"A plain Error (not a Nest exception) thrown by SlotsOutputService.getDuration() when eventTypeId is provided but eventTypesRepository.getEventTypeWithDuration(eventTypeId) returns null. Because this is a raw Error rather than a NotFoundException, Nest's default exception filter will surface it as HTTP 500 unless a custom filter intercepts it — a likely defect versus the 'Event Type not found' NotFoundException used elsewhere.","triggerScenarios":"GET /v2/slots with eventTypeId pointing to a deleted, never-existed, or organization-isolated event type the caller cannot access; a duration-only request where the caller omits duration and supplies a stale eventTypeId.","commonSituations":"Client caches an eventTypeId after the event type was deleted; cross-tenant access; race between event-type deletion and a slot request; test fixtures using random ids.","solutions":["Provide duration directly instead of relying solely on eventTypeId so getDuration short-circuits before the lookup.","Confirm the eventTypeId exists for the caller via the event-types endpoint before requesting slots.","If you maintain this service, change `throw new Error('Event type not found')` to `throw new NotFoundException(...)` so clients get a correct 404."],"exampleFix":"// before\nif (!eventType) {\n  throw new Error(\"Event type not found\");\n}\n// after — proper HTTP semantics\nif (!eventType) {\n  throw new NotFoundException(\"Event type not found\");\n}","handlingStrategy":"validation","validationCode":"async function ensureEventTypeExists(eventTypeId: number) {\n  const et = await api.getEventTypeWithDuration(eventTypeId).catch(() => null);\n  if (!et) throw new Error(`Event type ${eventTypeId} not found`);\n  return et;\n}","typeGuard":"const eventTypeExists = async (eventTypeId: number): Promise<boolean> =>\n  Boolean(await api.getEventTypeWithDuration(eventTypeId).catch(() => null));","tryCatchPattern":"try { await api.getSlots({ eventTypeId }); }\ncatch (e) { if (/event type not found/i.test(e.message)) { refreshEventTypes(); } else throw e; }","preventionTips":["Send duration explicitly so the event-type lookup is bypassed when possible.","Validate the eventTypeId exists for the caller before requesting slots.","Maintainer: replace throw new Error(...) with throw new NotFoundException(...) for correct 404 semantics."],"tags":["slots","event-type","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"}