{"record":{"id":"e76d285c4668baf8","repo":"calcom/cal.diy","slug":"invalid-date","errorCode":null,"errorMessage":"Invalid Date.","messagePattern":"Invalid Date\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/modules/ooo/inputs/ooo.input.ts","lineNumber":23,"sourceCode":"\nimport { SkipTakePagination } from \"@calcom/platform-types\";\n\nexport enum OutOfOfficeReason {\n  UNSPECIFIED = \"unspecified\",\n  VACATION = \"vacation\",\n  TRAVEL = \"travel\",\n  SICK_LEAVE = \"sick\",\n  PUBLIC_HOLIDAY = \"public_holiday\",\n}\n\nexport type OutOfOfficeReasonType = `${OutOfOfficeReason}`;\n\nconst isDateString = (dateString: string) => {\n  try {\n    const isoDateRegex = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{3})?Z$/;\n    return isoDateRegex.test(dateString);\n  } catch {\n    throw new BadRequestException(\"Invalid Date.\");\n  }\n};\n\nexport class CreateOutOfOfficeEntryDto {\n  @Transform(({ value }: { value: string }) => {\n    if (isDateString(value)) {\n      const date = new Date(value);\n      date.setUTCHours(0, 0, 0, 0);\n      return date;\n    }\n    throw new BadRequestException(\"Invalid Date.\");\n  })\n  @IsDate()\n  @ApiProperty({\n    description: \"The start date and time of the out of office period in ISO 8601 format in UTC timezone.\",\n    example: \"2023-05-01T00:00:00.000Z\",\n  })\n  start!: Date;","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/ooo/inputs/ooo.input.ts#L5-L41","documentation":"Thrown inside the catch block of isDateString() in the OOO (out-of-office) DTO transformer. isDateString() runs a strict ISO-8601 UTC regex against the input; the try/catch is a defensive guard around RegExp.prototype.test(). In practice RegExp.test() coerces its argument to a string and does not throw for normal values, so this branch is effectively unreachable for well-typed string inputs and only fires if a non-stringable value (e.g. a Symbol or a getter that throws) reaches the regex at runtime despite the TypeScript signature.","triggerScenarios":"A POST/PATCH to /v2/ooo (create/update out-of-office entry) where the request body reaches the @Transform pipe with a value whose toString/getter throws during regex.test(). Cannot be triggered by an ordinary malformed date string — those fall through to the line-34 throw instead.","commonSituations":"A client serializing a Date object, BigInt, or Symbol into the start/end JSON field; a class-transformer / class-validator pipeline misconfigured to pass non-primitives; a custom serialization layer that injects objects with throwing toJSON() hooks.","solutions":["Confirm the request body sends start/end as ISO-8601 strings (e.g. \"2023-05-01T00:00:00.000Z\"), never as Date objects or other primitives.","If you maintain this code, make isDateString() return false instead of throwing on a failed test — the catch is dead for strings and the line-34 path already handles the negative case.","Add a class-validator @IsString() / @Matches() guard before @Transform so non-string values are rejected earlier with a clearer message."],"exampleFix":"// before\nconst isDateString = (dateString: string) => {\n  try {\n    const isoDateRegex = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{3})?Z$/;\n    return isoDateRegex.test(dateString);\n  } catch {\n    throw new BadRequestException(\"Invalid Date.\");\n  }\n};\n// after (remove the unreachable catch; let the caller throw)\nconst ISO_DATE_REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{3})?Z$/;\nconst isDateString = (dateString: string): boolean => ISO_DATE_REGEX.test(dateString);","handlingStrategy":"validation","validationCode":"const ISO = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/;\nconst ensureIsoString = (v: unknown): string => {\n  if (typeof v !== 'string' || !ISO.test(v))\n    throw new Error('start/end must be ISO-8601 UTC string');\n  return v;\n};","typeGuard":"const isIsoDateString = (v: unknown): v is string =>\n  typeof v === 'string' && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(v);","tryCatchPattern":null,"preventionTips":["Always serialize dates with Date.prototype.toISOString() before sending.","Never pass Date objects, BigInt, or Symbols into the start/end JSON fields.","Add a class-validator @Matches(/...Z$/) decorator upstream of @Transform."],"tags":["date-validation","nestjs","dto","unreachable-code","ooo"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}