calcom/cal.diy · warning · BadRequestException

Invalid ${key} minutes. Expected value between 0 and 59

Error message

Invalid ${key} minutes. Expected value between 0 and 59

What it means

Thrown by transformStringToDate when the parsed minutes value falls outside the valid 0–59 range. Extracted from the second colon-separated segment and converted via Number(). The ${key} identifies the offending field (startTime or endTime). Values like 60, -1, or out-of-range numbers trigger HTTP 400.

Source

Thrown at apps/api/v2/src/platform/schedules/schedules_2024_04_15/inputs/create-availability.input.ts:50

    );
  }

  const timePart = dateTimeParts[1].split(".")[0]; // Removes milliseconds
  const parts = timePart.split(":");

  if (parts.length !== 3) {
    throw new BadRequestException(
      `Invalid time format. Expected format(ISO8061): 2025-0412T13:17:56.324Z. Received: ${value}`
    );
  }
  const [hours, minutes, seconds] = parts.map(Number);

  if (hours < 0 || hours > 23) {
    throw new BadRequestException(`Invalid ${key} hours. Expected value between 0 and 23`);
  }

  if (minutes < 0 || minutes > 59) {
    throw new BadRequestException(`Invalid ${key} minutes. Expected value between 0 and 59`);
  }

  if (seconds < 0 || seconds > 59) {
    throw new BadRequestException(`Invalid ${key} seconds. Expected value between 0 and 59`);
  }

  return new Date(new Date().setUTCHours(hours, minutes, seconds, 0));
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Ensure minutes in the time string are between 0 and 59.
  2. Use date.setMinutes() and toISOString() rather than constructing the string manually.
  3. Add client-side validation of each time component before the API call.

Example fix

// before
"startTime": "2025-04-12T09:60:00.000Z"
// after
"startTime": new Date(2025, 3, 12, 10, 0, 0).toISOString()
Defensive patterns

Strategy: validation

Validate before calling

function validateMinutes(isoString: string, fieldName: string): void {
  const timePart = isoString.split('T')[1]?.split('.')[0];
  const minutes = Number(timePart?.split(':')[1]);
  if (isNaN(minutes) || minutes < 0 || minutes > 59) {
    throw new Error(`${fieldName}: minutes must be 0-59, got ${minutes}`);
  }
}

validateMinutes(item.startTime, 'startTime');

Type guard

function hasValidMinutes(isoString: string): boolean {
  const timePart = isoString.split('T')[1]?.split('.')[0];
  if (!timePart) return false;
  const minutes = Number(timePart.split(':')[1]);
  return !isNaN(minutes) && minutes >= 0 && minutes <= 59;
}

Prevention

When it happens

Trigger: Sending a time with minutes = 60 or higher (e.g., '09:60:00'); sending negative minutes; edge case where client-side modular arithmetic produces 59+ after timezone shifting.

Common situations: Time zone conversion that wraps minutes incorrectly; manual string construction with arithmetic errors; clock UI that allows entering 60 minutes.

Related errors


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