calcom/cal.diy · error · InternalServerErrorException

error?.message ?? errMsg

Error message

error?.message ?? errMsg

What it means

This is the message expression inside handleBookingErrors for the generic Error branch — when the caught error is an Error instance but not an HttpError, not an HttpException, and its message doesn't match any ErrorCode enum value. The handler throws a 500 InternalServerErrorException with the error's message, falling back to the contextual errMsg (e.g., 'Error while creating recurring booking.').

Source

Thrown at apps/api/v2/src/platform/bookings/2024-04-15/controllers/bookings.controller.ts:604

  ): void {
    const errMsg =
      type === "no-show"
        ? `Error while marking no-show.`
        : `Error while creating ${type ? `${type} ` : ""}booking.`;
    if (err instanceof HttpError) {
      const httpError = err as HttpError;
      throw new HttpException(httpError?.message ?? errMsg, httpError?.statusCode ?? 500);
    }

    if (err instanceof Error) {
      const error = err as Error;
      if (err instanceof HttpException) {
        throw new HttpException(err.getResponse(), err.getStatus());
      }
      if (Object.values(ErrorCode).includes(error.message as unknown as ErrorCode)) {
        throw new HttpException(error.message, 400);
      }
      throw new InternalServerErrorException(error?.message ?? errMsg);
    }

    throw new InternalServerErrorException(errMsg);
  }

  private transformToBoolean(v?: string): boolean {
    return v && typeof v === "string" ? v.toLowerCase() === "true" : false;
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Check server logs for the full error stack trace — the original Error.message is forwarded but the stack is only in logs.
  2. If the message references a database error (e.g., 'Connection refused', 'PrismaClientInitializationError'), check database connectivity and env vars (DIRECT_URL, DATABASE_URL).
  3. If the message references a null/undefined access, inspect the booking request body for missing required fields.
  4. File a bug report with the error message and the request payload (minus sensitive data) — this path indicates an unhandled error type.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await api.createBooking(payload);
} catch (err) {
  if (err.statusCode === 500) {
    // Unexpected internal error — the message may contain a hint
    console.error('Internal booking error:', err.message);
    // Optionally retry with exponential backoff for transient errors
    if (isTransientError(err.message)) {
      await retryWithBackoff(() => api.createBooking(payload));
    }
  } else { throw err; }
}

Prevention

When it happens

Trigger: Any unexpected error during booking creation/cancellation/no-show that doesn't fit the typed error categories. Examples: Prisma database connection errors, serialization errors, null reference errors in the booking service, unexpected third-party API failures that throw plain Errors, or assertion failures.

Common situations: Database connectivity issues, transient Prisma errors (P1001 connection timed out), JSON parsing failures in metadata, missing required fields that bypass validation, or unhandled edge cases in the booking creation pipeline. This is the catch-all for genuinely unexpected errors.

Related errors


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