calcom/cal.diy · error · NotFoundException

Event type with id ${eventTypeId} not found

Error message

Event type with id ${eventTypeId} not found

What it means

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.

Source

Thrown at apps/api/v2/src/modules/teams/event-types/services/teams-event-types.service.ts:76

    const { hosts, children, destinationCalendar, ...rest } = body;

    const { eventType: eventTypeCreated } = await createEventType({
      input: { teamId: teamId, ...rest },
      ctx: {
        user: eventTypeUser,
        // @ts-ignore - prisma type mismatch between PrismaClient versions
        prisma: this.dbWrite.prisma,
      },
    });

    return this.updateTeamEventType(eventTypeCreated.id, teamId, body, user, false);
  }

  async validateEventTypeExists(teamId: number, eventTypeId: number) {
    const eventType = await this.teamsEventTypesRepository.getTeamEventType(teamId, eventTypeId);

    if (!eventType) {
      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
    }
  }

  async getUserToCreateTeamEvent(user: UserWithProfile) {
    const profileId = this.usersService.getUserMainProfile(user)?.id;

    return {
      id: user.id,
      role: user.role,
      organizationId: null,
      organization: { id: null, isOrgAdmin: false, metadata: {}, requestedSlug: null },
      profile: { id: profileId || null },
      metadata: user.metadata,
      email: user.email,
    };
  }

  async getTeamEventType(teamId: number, eventTypeId: number): Promise<DatabaseTeamEventType | null> {

View on GitHub (pinned to 176037d0af)

Solutions

  1. List the team's event types with GET /v2/teams/{teamId}/event-types and use an id from that list.
  2. Confirm the eventTypeId belongs to the teamId in the URL before calling mutating endpoints.
  3. If the event type was deleted, recreate it or inform the user.
Defensive patterns

Strategy: validation

Validate before calling

async function assertTeamEventType(api, teamId: number, eventTypeId: number) {
  const list = await api.getTeamEventTypes(teamId);
  if (!list.some(et => et.id === eventTypeId)) {
    throw new NotFoundError(`Event type ${eventTypeId} is not part of team ${teamId}`);
  }
}

Type guard

function eventTypeBelongsToTeam(
  et: { teamId?: number | null },
  teamId: number
): boolean {
  return et?.teamId === teamId;
}

Try / catch

try {
  await api.updateTeamEventType(teamId, eventTypeId, body);
} catch (e) {
  if (e.status === 404 && /Event type with id/.test(e.message)) {
    // refresh the team's event type list, reprompt
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/bf85860d46ce1f46. Report an issue: GitHub.