{"record":{"id":"1830323bfca4c7c9","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypeid-not-found","errorCode":null,"errorMessage":"Event type with id ${eventTypeId} not found","messagePattern":"Event type with id (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts","lineNumber":106,"sourceCode":"  async getUserEventType(user: UserWithProfile, eventTypeId: number) {\n    const organizationId = this.usersService.getUserMainOrgId(user);\n\n    const isUserOrganizationAdmin = organizationId\n      ? await this.membershipsRepository.isUserOrganizationAdmin(user.id, organizationId)\n      : false;\n\n    const eventType = await getEventTypeById({\n      currentOrganizationId: this.usersService.getUserMainOrgId(user),\n      eventTypeId,\n      userId: user.id,\n      userLocale: user.locale ?? \"en\",\n      prisma: this.dbRead.prisma as unknown as PrismaClient,\n      isUserOrganizationAdmin,\n      isTrpcCall: true,\n    });\n\n    if (!eventType) {\n      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);\n    }\n\n    if (!isUserOrganizationAdmin) {\n      if (eventType?.team?.id) {\n        await this.checkTeamOwnsEventType(user.id, eventType.eventType.id, eventType.team.id);\n      } else {\n        this.eventTypeService.checkUserOwnsEventType(user.id, eventType.eventType);\n      }\n    }\n\n    // note (Lauris): don't show platform owner as one of the people that can be assigned to managed team event type\n    const onlyManagedTeamMembers = eventType.teamMembers.filter((user) => user.isPlatformManaged);\n    eventType.teamMembers = onlyManagedTeamMembers;\n\n    return eventType;\n  }\n\n  async getUserEventTypes(userId: number) {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts#L88-L124","documentation":"Thrown by EventTypesAtomService.getUserEventType when getEventTypeById returns null for the given eventTypeId. The getEventTypeById function (from @calcom/platform-libraries) performs a complex query that filters by the user's organization, userId, and whether the user is an organization admin. If no event type matches all criteria, it returns null and this exception fires with NotFoundException (HTTP 404).","triggerScenarios":"Calling GET /v2/event-types/:id with an eventTypeId that doesn't exist, belongs to a different user, or is in an organization the caller doesn't belong to. The event type is a team event and the user is not a member of that team. The currentOrganizationId doesn't match the event type's organization.","commonSituations":"Using an eventTypeId from a different user's account. Event type was deleted or archived. Organization membership changed (user removed from org) making previously accessible event types invisible. isUserOrganizationAdmin is false and the event type is in an org the user belongs to but doesn't own.","solutions":["Verify the eventTypeId belongs to the authenticated user or a team they are a member of.","If the user is in an organization, confirm they still have access (check membership and organization assignment).","Use GET /v2/event-types to list the user's accessible event types and confirm the ID is present.","For team event types, ensure the user has an accepted membership with ADMIN or OWNER role, or is an organization admin."],"exampleFix":"// before: using a hardcoded eventTypeId\nconst eventType = await api.get(`/v2/event-types/999`);\n\n// after: verify ownership before accessing\nconst myEventTypes = await api.get('/v2/event-types');\nconst valid = myEventTypes.find(et => et.id === targetEventTypeId);\nif (!valid) {\n  throw new Error(`Event type ${targetEventTypeId} not found or not accessible by this user.`);\n}\nconst eventType = await api.get(`/v2/event-types/${targetEventTypeId}`);","handlingStrategy":"validation","validationCode":"// Verify the event type is accessible by this user before fetching details\nconst verifyEventTypeAccess = async (api: ApiClient, eventTypeId: number): Promise<boolean> => {\n  const eventTypes = await api.get('/v2/event-types');\n  return eventTypes.some((et: { id: number }) => et.id === eventTypeId);\n};\nif (!await verifyEventTypeAccess(api, targetId)) {\n  throw new Error(`Event type ${targetId} is not accessible by this user.`);\n}","typeGuard":null,"tryCatchPattern":"// Handle 404 on event-type fetch\ntry {\n  const eventType = await api.get(`/v2/event-types/${id}`);\n  return eventType;\n} catch (err: any) {\n  if (err?.response?.status === 404) {\n    return null; // signal not-found to caller\n  }\n  throw err;\n}","preventionTips":["Before accessing a specific event type by ID, verify it appears in the user's event-type list.","Handle event-type deletions in the UI by refreshing the list when a 404 is received.","For team event types, verify the user's membership role is ADMIN or OWNER before accessing."],"tags":["not-found","event-types","nestjs","api-v2","atoms","authorization"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}