calcom/cal.diy · error · NotFoundException

Event type with slug ${body.eventTypeSlug} belonging to user

Error message

Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} not found.

What it means

Thrown by ErrorsBookingsService_2024_08_13.handleEventTypeToBeBookedNotFound when a booking request supplies username + eventTypeSlug but no organizationSlug, and no matching user-owned event type was resolved upstream. It is a NotFoundException (HTTP 404). The same dispatcher routes different combinations (user vs team, with/without org) to different messages — this branch is specifically the non-org user-slug lookup miss.

Source

Thrown at apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts:12

import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
import { Logger } from "@nestjs/common";

import { CreateBookingInput } from "@calcom/platform-types";

@Injectable()
export class ErrorsBookingsService_2024_08_13 {
  private readonly logger = new Logger("ErrorsBookingsService_2024_08_13");

  handleEventTypeToBeBookedNotFound(body: CreateBookingInput): never {
    if (body.username && body.eventTypeSlug && !body.organizationSlug) {
      throw new NotFoundException(
        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} not found.`
      );
    }
    if (body.username && body.eventTypeSlug && body.organizationSlug) {
      throw new NotFoundException(
        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} within organization ${body.organizationSlug} not found.`
      );
    }
    if (body.teamSlug && body.eventTypeSlug && !body.organizationSlug) {
      throw new NotFoundException(
        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} not found.`
      );
    }
    if (body.teamSlug && body.eventTypeSlug && body.organizationSlug) {
      throw new NotFoundException(
        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} within organization ${body.organizationSlug} not found.`
      );
    }

View on GitHub (pinned to 176037d0af)

Solutions

  1. Verify the user exists and the slug is current via GET /v2/event-types?username={username} (or the platform event-types endpoint) before booking.
  2. Strip whitespace and trailing slashes from eventTypeSlug and username in the client before sending.
  3. If the user is part of an organization, include organizationSlug so the org-scoped branch resolves instead.
  4. Confirm the event type is published and not hidden from the API.

Example fix

// before
body: { username: 'alice ', eventTypeSlug: 'intro-call/' }

// after
body: { username: 'alice', eventTypeSlug: 'intro-call' }
Defensive patterns

Strategy: validation

Validate before calling

const username = body.username?.trim();
const eventTypeSlug = body.eventTypeSlug?.trim().replace(/\/$/, '');
if (!username || !eventTypeSlug) throw new Error('username and eventTypeSlug required');
const et = await api.get(`/v2/event-types?username=${encodeURIComponent(username)}&slug=${encodeURIComponent(eventTypeSlug)}`);
if (!et.data.length) throw new Error('event type not found — check slug/user');

Type guard

const hasUserSlugCombo = (b: CreateBookingInput): boolean =>
  !!(b.username && b.eventTypeSlug && !b.organizationSlug);

Try / catch

try { await api.post('/v2/bookings', body); }
catch (e) {
  if (e.response?.status === 404) { /* re-fetch event type, prompt user for correct slug */ }
  else throw e;
}

Prevention

When it happens

Trigger: POST /v2/bookings with body { username, eventTypeSlug } (and no organizationSlug) where the user does not exist, the slug is misspelled/trailing-spaced, the event type belongs to a different user, or the event type is hidden/disabled. The bookings controller calls handleEventTypeToBeBookedNotFound only after the eventType lookup returned null.

Common situations: Copy/paste of a slug from a URL with a trailing slash; renamed event type slug after a rebrand; user moved under an organization so the non-org lookup no longer resolves; event type set to 'hidden' or 'unpublished'; dev environment seeded with different usernames than production.

Related errors


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