{"record":{"id":"b3eacc96ce22dfa0","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypeid-does-not-exist-b3eacc","errorCode":null,"errorMessage":"Event type with ID=${eventTypeId} does not exist.","messagePattern":"Event type with ID=(.+?) does not exist\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/event-types/event-types_2024_04_15/services/event-types.service.ts","lineNumber":191,"sourceCode":"\n  async getUserToUpdateEvent(user: UserWithProfile) {\n    const profileId = this.usersService.getUserMainProfile(user)?.id || null;\n    const selectedCalendars = await this.selectedCalendarsRepository.getUserSelectedCalendars(user.id);\n    const eventTypeSelectedCalendars =\n      await this.selectedCalendarsRepository.getUserEventTypeSelectedCalendar(user.id);\n    return {\n      ...user,\n      locale: user.locale ?? \"en\",\n      profile: { id: profileId },\n      userLevelSelectedCalendars: selectedCalendars,\n      allSelectedCalendars: [...eventTypeSelectedCalendars, ...selectedCalendars],\n    };\n  }\n\n  async deleteEventType(eventTypeId: number, userId: number) {\n    const existingEventType = await this.eventTypesRepository.getEventTypeById(eventTypeId);\n    if (!existingEventType) {\n      throw new NotFoundException(`Event type with ID=${eventTypeId} does not exist.`);\n    }\n\n    this.checkUserOwnsEventType(userId, existingEventType);\n\n    return this.eventTypesRepository.deleteEventType(eventTypeId);\n  }\n\n  checkUserOwnsEventType(userId: number, eventType: Pick<EventType, \"id\" | \"userId\">) {\n    if (userId !== eventType.userId) {\n      throw new ForbiddenException(`User with ID=${userId} does not own event type with ID=${eventType.id}`);\n    }\n  }\n}\n","sourceCodeStart":173,"sourceCodeEnd":205,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/event-types/event-types_2024_04_15/services/event-types.service.ts#L173-L205","documentation":"Thrown by EventTypesService_2024_04_15.deleteEventType (DELETE /v2/event-types/:eventTypeId) when eventTypesRepository.getEventTypeById returns null — no row exists with that id at all. Note the message uses 'ID=' (uppercase) and 'does not exist', distinct from the lowercase 'id' phrasing used elsewhere — useful for log grep.","triggerScenarios":"DELETE /v2/event-types/999 where the id does not exist; the event type was already deleted; the id is valid but belongs to a soft-deleted row excluded by the repository filter.","commonSituations":"Double-delete (second DELETE after success); id from a different deployment; the row was purged by a GDPR/retention job; frontend caching a deleted id.","solutions":["Make DELETE idempotent on the client: treat 404 as success.","Refresh the event type list after a delete so the UI cannot target a gone id.","Confirm the id came from the same environment's GET response.","If you need create+delete semantics, store the returned id and delete by that exact value."],"exampleFix":"// before\nawait api.delete(`/v2/event-types/${id}`);\n// after\ntry { await api.delete(`/v2/event-types/${id}`); }\ncatch (e) { if (e.response?.status !== 404) throw e; /* already gone */ }","handlingStrategy":"try-catch","validationCode":"// Confirm existence before DELETE (optional — idempotent catch is usually enough)\ntry {\n  await api.get(`/v2/event-types/${id}`);\n} catch (e) {\n  if (e.response?.status === 404) return; // already gone\n  throw e;\n}","typeGuard":"function isExistingId(list: unknown, id: number): boolean {\n  return Array.isArray(list) && list.some((e) => typeof e === 'object' && e !== null && (e as any).id === id);\n}","tryCatchPattern":"try {\n  await api.delete(`/v2/event-types/${id}`);\n} catch (e) {\n  if (e.response?.status === 404) return; // idempotent success\n  throw e;\n}","preventionTips":["Make DELETE idempotent on the client: swallow 404.","Refresh the list after every delete so stale ids cannot be re-targeted.","Log delete outcomes so a second delete attempt is recognizable."],"tags":["nestjs","not-found","event-types","idempotency","rest-api"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}