{"record":{"id":"8a109b18c74abb9e","repo":"calcom/cal.diy","slug":"invalid-key-minutes-expected-value-between-0-a","errorCode":null,"errorMessage":"Invalid ${key} minutes. Expected value between 0 and 59","messagePattern":"Invalid (.+?) minutes\\. Expected value between 0 and 59","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apps/api/v2/src/platform/schedules/schedules_2024_04_15/inputs/create-availability.input.ts","lineNumber":50,"sourceCode":"    );\n  }\n\n  const timePart = dateTimeParts[1].split(\".\")[0]; // Removes milliseconds\n  const parts = timePart.split(\":\");\n\n  if (parts.length !== 3) {\n    throw new BadRequestException(\n      `Invalid time format. Expected format(ISO8061): 2025-0412T13:17:56.324Z. Received: ${value}`\n    );\n  }\n  const [hours, minutes, seconds] = parts.map(Number);\n\n  if (hours < 0 || hours > 23) {\n    throw new BadRequestException(`Invalid ${key} hours. Expected value between 0 and 23`);\n  }\n\n  if (minutes < 0 || minutes > 59) {\n    throw new BadRequestException(`Invalid ${key} minutes. Expected value between 0 and 59`);\n  }\n\n  if (seconds < 0 || seconds > 59) {\n    throw new BadRequestException(`Invalid ${key} seconds. Expected value between 0 and 59`);\n  }\n\n  return new Date(new Date().setUTCHours(hours, minutes, seconds, 0));\n}\n","sourceCodeStart":32,"sourceCodeEnd":59,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/schedules/schedules_2024_04_15/inputs/create-availability.input.ts#L32-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"Time zone conversion that wraps minutes incorrectly; manual string construction with arithmetic errors; clock UI that allows entering 60 minutes.","solutions":["Ensure minutes in the time string are between 0 and 59.","Use date.setMinutes() and toISOString() rather than constructing the string manually.","Add client-side validation of each time component before the API call."],"exampleFix":"// before\n\"startTime\": \"2025-04-12T09:60:00.000Z\"\n// after\n\"startTime\": new Date(2025, 3, 12, 10, 0, 0).toISOString()","handlingStrategy":"validation","validationCode":"function validateMinutes(isoString: string, fieldName: string): void {\n  const timePart = isoString.split('T')[1]?.split('.')[0];\n  const minutes = Number(timePart?.split(':')[1]);\n  if (isNaN(minutes) || minutes < 0 || minutes > 59) {\n    throw new Error(`${fieldName}: minutes must be 0-59, got ${minutes}`);\n  }\n}\n\nvalidateMinutes(item.startTime, 'startTime');","typeGuard":"function hasValidMinutes(isoString: string): boolean {\n  const timePart = isoString.split('T')[1]?.split('.')[0];\n  if (!timePart) return false;\n  const minutes = Number(timePart.split(':')[1]);\n  return !isNaN(minutes) && minutes >= 0 && minutes <= 59;\n}","tryCatchPattern":null,"preventionTips":["Use Date objects and toISOString() to produce valid minute values automatically.","Never perform minute arithmetic that can exceed 59 without carrying over to hours.","Validate the minutes component client-side before sending the request."],"tags":["validation","time","range-check","input","schedules"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}