{"record":{"id":"69438723bb41f586","repo":"mermaid-js/mermaid","slug":"failed-to-find-a-valid-date-that-was-not-excluded","errorCode":null,"errorMessage":"Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","messagePattern":"Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/gantt/ganttDb.js","lineNumber":280,"sourceCode":" * @param {string[]} excludes - Dates or days to exclude.\n * @param {string[]} includes - Dates to always include, even if they match the excludes.\n * @returns {[endTime: dayjs.Dayjs, renderEndTime: Date | null]} The new `endTime`, and the end time to render.\n * `renderEndTime` may be `null` if `startTime` is newer than `endTime`.\n * @throws {Error} If a valid end time cannot be found after 10,000 iterations.\n */\nconst fixTaskDates = function (startTime, endTime, dateFormat, excludes, includes) {\n  let invalid = false;\n  let renderEndTime = null;\n  const maxEndTime = endTime.add(10000, 'd');\n  while (startTime <= endTime) {\n    if (!invalid) {\n      renderEndTime = endTime.toDate();\n    }\n    invalid = isInvalidDate(startTime, dateFormat, excludes, includes);\n    if (invalid) {\n      endTime = endTime.add(1, 'd');\n      if (endTime > maxEndTime) {\n        throw new Error(\n          'Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.'\n        );\n      }\n    }\n    startTime = startTime.add(1, 'd');\n  }\n  return [endTime, renderEndTime];\n};\n\nconst getStartDate = function (prevTime, dateFormat, str) {\n  str = str.trim();\n\n  // Helper function to check if format is a timestamp format (x or X)\n  const isTimestampFormat = (format) => {\n    const trimmedFormat = format.trim();\n    return trimmedFormat === 'x' || trimmedFormat === 'X';\n  };\n","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/gantt/ganttDb.js#L262-L298","documentation":"Error \"Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.\" thrown in mermaid-js/mermaid.","triggerScenarios":"Thrown at packages/mermaid/src/diagrams/gantt/ganttDb.js:280 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}