{"record":{"id":"a8e2da909f19e5c6","repo":"calcom/cal.diy","slug":"event-type-with-uid-uid-not-found","errorCode":null,"errorMessage":"Event type with uid ${uid} not found","messagePattern":"Event type with uid (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts","lineNumber":328,"sourceCode":"    return apps[0];\n  }\n\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,","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts#L310-L346","documentation":"Thrown by EventTypesAtomService.getUserPaymentInfo when the payment and booking both exist, but the booking's eventType relation is null. The code destructures eventType from _booking (the booking relation), and if it's absent, the event type metadata, users, team, and profile information cannot be assembled, so NotFoundException (HTTP 404) is thrown. This indicates the booking references an event type that no longer exists.","triggerScenarios":"A booking exists whose eventTypeId references a deleted event type. The event type was hard-deleted after the booking was created but before the payment info was queried. A data migration removed event types without updating bookings. The booking was created through a legacy flow that didn't properly set the event type relation.","commonSituations":"Admin deletes an event type that has existing bookings with payments. A test or seed script created bookings with invalid eventTypeId references. Schema migration that changed event type IDs without updating booking foreign keys. Read replica lag where the event type hasn't propagated.","solutions":["Check the booking's eventTypeId in the database: SELECT id, eventTypeId FROM booking WHERE uid = <booking_uid>.","Verify the eventTypeId still exists in the EventType table; if deleted, this is a data integrity issue.","Restore the deleted event type or update the booking to reference a valid event type if appropriate.","If this is read-replica lag, retry the request after a brief delay."],"exampleFix":"// before: no handling for missing event type on payment info\nconst info = await api.get(`/v2/atoms/payment-info/${paymentUid}`);\n// 404: Event type with uid not found\n\n// after: check data integrity and handle gracefully\n// DB diagnostic query:\n// SELECT b.uid, b.eventTypeId, et.id as et_exists\n// FROM \"Booking\" b LEFT JOIN \"EventType\" et ON b.\"eventTypeId\" = et.id\n// WHERE b.uid = '<booking_uid>' AND et.id IS NULL;\n// If results found: orphaned booking referencing a deleted event type.\n// Fix: either restore the event type or null-out the payment's booking association.","handlingStrategy":"try-catch","validationCode":"// Verify the booking's event type still exists before querying payment info\nconst verifyEventTypeForBooking = async (api: ApiClient, paymentUid: string): Promise<void> => {\n  const payment = await api.get(`/v2/payments/${paymentUid}`);\n  if (!payment?.booking?.eventTypeId) {\n    throw new Error('Booking has no event type. The event type may have been deleted.');\n  }\n};","typeGuard":null,"tryCatchPattern":"// Handle orphaned event type on 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('Event type with uid')) {\n    // Event type was deleted; return partial info or notify admin\n    return { error: 'event_type_deleted', paymentUid: uid };\n  }\n  throw err;\n}","preventionTips":["Before deleting an event type, check for existing bookings with payments and either archive instead of hard-delete or warn the admin.","Run data integrity audits: SELECT b.uid FROM booking b LEFT JOIN EventType et ON b.\"eventTypeId\" = et.id WHERE b.\"eventTypeId\" IS NOT NULL AND et.id IS NULL.","When restructuring event types, update booking references or use soft-delete with a 'deleted_at' flag."],"tags":["not-found","event-types","booking","payment","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"}