{"record":{"id":"955b748aabe32c1a","repo":"calcom/cal.diy","slug":"no-users-found-or-no-team-present-for-event-type-w","errorCode":null,"errorMessage":"No users found or no team present for event type with uid ${uid}","messagePattern":"No users found or no team present for event type with uid (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts","lineNumber":330,"sourceCode":"\n  async getUserPaymentInfo(uid: string) {\n    const rawPayment = await this.atomsRepository.getRawPayment(uid);\n    if (!rawPayment) throw new NotFoundException(`Payment with uid ${uid} not found`);\n    const { data, booking: _booking, ...restPayment } = rawPayment;\n    const payment = {\n      ...restPayment,\n      data: data as Record<string, unknown>,\n    };\n    if (!_booking) throw new NotFoundException(`Booking with uid ${uid} not found`);\n    const { startTime, endTime, eventType, ...restBooking } = _booking;\n    const booking = {\n      ...restBooking,\n      startTime: startTime.toString(),\n      endTime: endTime.toString(),\n    };\n    if (!eventType) throw new NotFoundException(`Event type with uid ${uid} not found`);\n    if (eventType.users.length === 0 && !eventType.team)\n      throw new NotFoundException(`No users found or no team present for event type with uid ${uid}`);\n    const [user] = eventType?.users.length\n      ? eventType.users\n      : [{ name: null, theme: null, hideBranding: null, username: null }];\n    const profile = {\n      name: eventType.team?.name || user?.name || null,\n      theme: (!eventType.team?.name && user?.theme) || null,\n      hideBranding: eventType.team?.hideBranding || user?.hideBranding || null,\n    };\n    return {\n      user,\n      eventType: {\n        ...eventType,\n        metadata: EventTypeMetaDataSchema.parse(eventType.metadata),\n      },\n      booking,\n      payment,\n      clientSecret: getClientSecretFromPayment(payment),\n      profile,","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts#L312-L348","documentation":"Thrown by EventTypesAtomService.getUserPaymentInfo when the event type exists but has zero users in its users relation AND no team assigned. The code at line 329 checks eventType.users.length === 0 && !eventType.team, meaning the event type is effectively orphaned — it has no individual assignees and no team owner. Without either, the profile (name, theme, hideBranding) cannot be determined, so the response is incomplete and a NotFoundException (HTTP 404) is thrown.","triggerScenarios":"An event type where all assigned users were deleted or removed, and the event type has no team. A managed event type whose team assignment was cleared. A data migration that restructured user-event-type assignments and left the relation empty. A circular reference issue where the event type points to users that no longer exist.","commonSituations":"User account deletion without reassigning their event types. Team event type converted to a user event type but with the team relation cleared and no users assigned. Seed data or test fixtures that create event types without users or teams. Org restructuring that moved all users away from an event type.","solutions":["Check the EventTypeUser join table: verify that users are assigned to the event type via SELECT * FROM \"EventTypeUser\" WHERE eventTypeId = <id>.","If users were removed, reassign at least one user or set a team on the event type.","For managed team event types, ensure the team relation is properly set in the EventType table.","Run a data integrity audit for event types with no users and no team: SELECT et.id FROM \"EventType\" et WHERE NOT EXISTS (SELECT 1 FROM \"EventTypeUser\" etu WHERE etu.\"eventTypeId\" = et.id) AND et.teamId IS NULL."],"exampleFix":"// before: no pre-check for event type ownership\n// (no client-side fix; this is a server-side data integrity issue)\n\n// after: diagnostic and remediation\n// 1. Diagnose:\n//    SELECT et.id, et.slug,\n//      (SELECT count(*) FROM \"EventTypeUser\" etu WHERE etu.\"eventTypeId\" = et.id) as user_count,\n//      et.\"teamId\"\n//    FROM \"EventType\" et\n//    WHERE et.id = <event_type_id>;\n// 2. Remediate:\n//    INSERT INTO \"EventTypeUser\" (\"eventTypeId\", \"userId\") VALUES (<et_id>, <user_id>);\n//    -- OR: UPDATE \"EventType\" SET \"teamId\" = <team_id> WHERE id = <et_id>;","handlingStrategy":"validation","validationCode":"// Check event type has at least one user or a team before relying on it\nconst verifyEventTypeOwnership = (eventType: {\n  users?: unknown[];\n  team?: unknown | null;\n}): void => {\n  const hasUsers = (eventType.users?.length ?? 0) > 0;\n  const hasTeam = eventType.team != null;\n  if (!hasUsers && !hasTeam) {\n    throw new Error('Event type has no assigned users and no team. Data integrity issue.');\n  }\n};","typeGuard":"interface OwnedEventType {\n  users: unknown[];\n  team?: { id: number } | null;\n}\nconst isOwnedEventType = (et: { users?: unknown[]; team?: unknown }): et is OwnedEventType =>\n  (et.users?.length ?? 0) > 0 || et.team != null;","tryCatchPattern":"// Handle orphaned event type in payment info\ntry {\n  return await api.get(`/v2/atoms/payment-info/${uid}`);\n} catch (err: any) {\n  const msg = err?.response?.data?.message ?? '';\n  if (err?.response?.status === 404 && msg.includes('No users found')) {\n    // Event type is orphaned; alert data team\n    alertDataTeam(`Orphaned event type detected for payment ${uid}`);\n    return null;\n  }\n  throw err;\n}","preventionTips":["Before deleting a user, reassign their event types to another user or convert them to team event types.","Run periodic audits for event types with no users and no team: SELECT et.id FROM EventType et WHERE NOT EXISTS (SELECT 1 FROM EventTypeUser etu WHERE etu.eventTypeId = et.id) AND et.teamId IS NULL.","When converting between user and team event types, ensure at least one ownership relation is set before removing the other."],"tags":["not-found","event-types","data-integrity","atoms","nestjs","api-v2"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}