calcom/cal.diy · warning · BadRequestException

Missing eventTypeId param.

Error message

Missing eventTypeId param.

What it means

Thrown by EventTypeOwnershipGuard.canActivate when the eventTypeId route param is absent. After the user check passes, the guard reads request.params?.eventTypeId and raises BadRequestException (HTTP 400) if it is falsy. This indicates the route path/controller mapping does not actually include :eventTypeId.

Source

Thrown at apps/api/v2/src/modules/event-types/guards/event-type-ownership.guard.ts:27

  NotFoundException,
} from "@nestjs/common";
import { Request } from "express";

@Injectable()
export class EventTypeOwnershipGuard implements CanActivate {
  constructor(private readonly eventTypesService: EventTypesService_2024_06_14) {}

  async canActivate(context: ExecutionContext): Promise<boolean> {
    const request = context.switchToHttp().getRequest<Request>();
    const user = request.user as ApiAuthGuardUser | undefined;
    const eventTypeIdParam = request.params?.eventTypeId;

    if (!user) {
      throw new ForbiddenException("EventTypeOwnershipGuard - No user associated with the request.");
    }

    if (!eventTypeIdParam) {
      throw new BadRequestException("Missing eventTypeId param.");
    }

    const eventTypeId = Number(eventTypeIdParam);
    if (!Number.isInteger(eventTypeId) || eventTypeId <= 0) {
      throw new BadRequestException("Invalid eventTypeId param.");
    }
    const eventType = await this.eventTypesService.getUserEventType(user.id, eventTypeId);
    if (!eventType) {
      // Mirrors EventTypesService behavior: NotFound when not owned or not present
      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
    }

    return true;
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Ensure the route path includes :eventTypeId, e.g. @Delete(':eventTypeId').
  2. If the param name must differ, update the guard to read the actual param name or use a shared constant.
  3. Do not apply this ownership guard to collection routes that have no id param.

Example fix

// before
@Delete(':id')
@UseGuards(EventTypeOwnershipGuard)

// after
@Delete(':eventTypeId')
@UseGuards(EventTypeOwnershipGuard)
Defensive patterns

Strategy: validation

Validate before calling

const eventTypeIdParam = request.params?.eventTypeId;
if (!eventTypeIdParam) {
  throw new BadRequestException('Missing eventTypeId param.');
}

Prevention

When it happens

Trigger: A route decorated with EventTypeOwnershipGuard whose path lacks the :eventTypeId segment, or the param name was renamed (e.g. :id) so request.params.eventTypeId is undefined. The guard refuses to proceed without a target id.

Common situations: Controller @Get/@Put/@Delete path template changed and :eventTypeId dropped or renamed; guard applied to a collection route (e.g. /event-types) instead of an item route (/event-types/:eventTypeId); typo in param name between path and guard.

Related errors


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