{"record":{"id":"bf85860d46ce1f46","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypeid-not-found-bf8586","errorCode":null,"errorMessage":"Event type with id ${eventTypeId} not found","messagePattern":"Event type with id (.+?) not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/teams/event-types/services/teams-event-types.service.ts","lineNumber":76,"sourceCode":"    const { hosts, children, destinationCalendar, ...rest } = body;\n\n    const { eventType: eventTypeCreated } = await createEventType({\n      input: { teamId: teamId, ...rest },\n      ctx: {\n        user: eventTypeUser,\n        // @ts-ignore - prisma type mismatch between PrismaClient versions\n        prisma: this.dbWrite.prisma,\n      },\n    });\n\n    return this.updateTeamEventType(eventTypeCreated.id, teamId, body, user, false);\n  }\n\n  async validateEventTypeExists(teamId: number, eventTypeId: number) {\n    const eventType = await this.teamsEventTypesRepository.getTeamEventType(teamId, eventTypeId);\n\n    if (!eventType) {\n      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);\n    }\n  }\n\n  async getUserToCreateTeamEvent(user: UserWithProfile) {\n    const profileId = this.usersService.getUserMainProfile(user)?.id;\n\n    return {\n      id: user.id,\n      role: user.role,\n      organizationId: null,\n      organization: { id: null, isOrgAdmin: false, metadata: {}, requestedSlug: null },\n      profile: { id: profileId || null },\n      metadata: user.metadata,\n      email: user.email,\n    };\n  }\n\n  async getTeamEventType(teamId: number, eventTypeId: number): Promise<DatabaseTeamEventType | null> {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/teams/event-types/services/teams-event-types.service.ts#L58-L94","documentation":"Thrown by TeamsEventTypesService.validateEventTypeExists after it queries getTeamEventType(teamId, eventTypeId). If no event type is found for that team/event-type pair, the service rejects with 404 NotFound. This validates ownership: the event type must belong to the given team before any further operation proceeds.","triggerScenarios":"An operation on /v2/teams/{teamId}/event-types/{eventTypeId} (create-child, assignment, etc.) where eventTypeId does not exist or does not belong to teamId, so getTeamEventType returns null.","commonSituations":"The caller used an eventTypeId from a different team. The event type was deleted. The user is a member of a different team and guessed an id. A URL parameter was transposed.","solutions":["List the team's event types with GET /v2/teams/{teamId}/event-types and use an id from that list.","Confirm the eventTypeId belongs to the teamId in the URL before calling mutating endpoints.","If the event type was deleted, recreate it or inform the user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function assertTeamEventType(api, teamId: number, eventTypeId: number) {\n  const list = await api.getTeamEventTypes(teamId);\n  if (!list.some(et => et.id === eventTypeId)) {\n    throw new NotFoundError(`Event type ${eventTypeId} is not part of team ${teamId}`);\n  }\n}","typeGuard":"function eventTypeBelongsToTeam(\n  et: { teamId?: number | null },\n  teamId: number\n): boolean {\n  return et?.teamId === teamId;\n}","tryCatchPattern":"try {\n  await api.updateTeamEventType(teamId, eventTypeId, body);\n} catch (e) {\n  if (e.status === 404 && /Event type with id/.test(e.message)) {\n    // refresh the team's event type list, reprompt\n  } else throw e;\n}","preventionTips":["Source eventTypeId from the team's event-type list, never from a global list or another team.","Keep the teamId in the URL in sync with the event type used in the body.","Refresh the list after deletes to avoid acting on stale ids."],"tags":["teams","event-type","not-found","api-v2","ownership"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}