calcom/cal.diy · error · Error

Event type not found

Error message

Event type not found

What it means

A plain Error (not a Nest exception) thrown by SlotsOutputService.getDuration() when eventTypeId is provided but eventTypesRepository.getEventTypeWithDuration(eventTypeId) returns null. Because this is a raw Error rather than a NotFoundException, Nest's default exception filter will surface it as HTTP 500 unless a custom filter intercepts it — a likely defect versus the 'Event Type not found' NotFoundException used elsewhere.

Source

Thrown at apps/api/v2/src/modules/slots/slots-2024-04-15/services/slots-output.service.ts:99

          ...(slot.attendees ? { attendees: slot.attendees } : {}),
          ...(slot.bookingUid ? { bookingUid: slot.bookingUid } : {}),
        };
      });
      return acc;
    }, {});

    return { slots };
  }

  private async getDuration(duration?: number, eventTypeId?: number): Promise<number> {
    if (duration) {
      return duration;
    }

    if (eventTypeId) {
      const eventType = await this.eventTypesRepository.getEventTypeWithDuration(eventTypeId);
      if (!eventType) {
        throw new Error("Event type not found");
      }
      return eventType.length;
    }

    throw new Error("duration or eventTypeId is required");
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Provide duration directly instead of relying solely on eventTypeId so getDuration short-circuits before the lookup.
  2. Confirm the eventTypeId exists for the caller via the event-types endpoint before requesting slots.
  3. If you maintain this service, change `throw new Error('Event type not found')` to `throw new NotFoundException(...)` so clients get a correct 404.

Example fix

// before
if (!eventType) {
  throw new Error("Event type not found");
}
// after — proper HTTP semantics
if (!eventType) {
  throw new NotFoundException("Event type not found");
}
Defensive patterns

Strategy: validation

Validate before calling

async function ensureEventTypeExists(eventTypeId: number) {
  const et = await api.getEventTypeWithDuration(eventTypeId).catch(() => null);
  if (!et) throw new Error(`Event type ${eventTypeId} not found`);
  return et;
}

Type guard

const eventTypeExists = async (eventTypeId: number): Promise<boolean> =>
  Boolean(await api.getEventTypeWithDuration(eventTypeId).catch(() => null));

Try / catch

try { await api.getSlots({ eventTypeId }); }
catch (e) { if (/event type not found/i.test(e.message)) { refreshEventTypes(); } else throw e; }

Prevention

When it happens

Trigger: GET /v2/slots with eventTypeId pointing to a deleted, never-existed, or organization-isolated event type the caller cannot access; a duration-only request where the caller omits duration and supplies a stale eventTypeId.

Common situations: Client caches an eventTypeId after the event type was deleted; cross-tenant access; race between event-type deletion and a slot request; test fixtures using random ids.

Related errors


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