{"record":{"id":"19af0a408659ccc0","repo":"mermaid-js/mermaid","slug":"line-definition-not-found","errorCode":null,"errorMessage":"Line definition not found","messagePattern":"Line definition not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/git/gitGraphRenderer.ts","lineNumber":840,"sourceCode":"      if (p1.y > p2.y) {\n        if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {\n          lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${\n            p1.y - offset\n          } L ${p2.x} ${p2.y}`;\n        } else {\n          lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${\n            p2.y\n          } L ${p2.x} ${p2.y}`;\n        }\n      }\n\n      if (p1.y === p2.y) {\n        lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;\n      }\n    }\n  }\n  if (lineDef === undefined) {\n    throw new Error('Line definition not found');\n  }\n  svg\n    .append('path')\n    .attr('d', lineDef)\n    .attr(\n      'class',\n      'arrow arrow' + calcColorIndex(colorClassNum!, THEME_COLOR_LIMIT, useColorTheme)\n    );\n};\n\nconst drawArrows = (\n  svg: d3.Selection<d3.BaseType, unknown, HTMLElement, any>,\n  commits: Map<string, Commit>\n) => {\n  const gArrows = svg.append('g').attr('class', 'commit-arrows');\n  [...commits.keys()].forEach((key) => {\n    const commit = commits.get(key);\n","sourceCodeStart":822,"sourceCodeEnd":858,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts#L822-L858","documentation":"Thrown at the end of drawArrow when the local variable lineDef is still undefined after every geometry branch was evaluated. lineDef is only assigned inside nested if/else blocks keyed on direction (TB/BT/LR), arrow rerouting, and coordinate relationships (p1.x vs p2.x, p1.y vs p2.y). If none of those conditions match — most notably when a commit position coordinate is NaN, making every comparison evaluate false — lineDef is never assigned and the safety check fires.","triggerScenarios":"A commit position stored in commitPos has x or y equal to NaN, so comparisons like p1.y < p2.y, p1.y > p2.y, and p1.y === p2.y are all false and no branch runs; or an unexpected dir value outside TB/BT/LR; or a rerouting path whose sub-conditions all miss.","commonSituations":"Usually a downstream symptom of error 60 or of a layout computation producing NaN (e.g. division by zero in getCommitPosition); appears after changing theme/layout config that alters commit spacing math; rare in stable releases.","solutions":["Treat this as a symptom: inspect the commit positions passed to drawArrow and look for NaN/undefined coordinates, then fix the upstream layout that produced them.","Temporarily switch the gitGraph direction to LR (default) to see if the throw disappears, isolating it to TB/BT geometry code.","Reduce the diagram to the smallest case that reproduces and report it upstream with the diagram text and mermaid version.","Upgrade to the latest mermaid patch release — geometry edge cases are fixed frequently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function positionsAreFinite(commitPos: Map<string, {x:number;y:number}>): boolean {\n  for (const p of commitPos.values()) {\n    if (!Number.isFinite(p.x) || !Number.isFinite(p.y)) return false;\n  }\n  return true;\n}","tryCatchPattern":"try {\n  await mermaid.render('g', diagramText);\n} catch (e) {\n  if (e instanceof Error && /Line definition not found/.test(e.message)) {\n    // This is a downstream symptom of bad positions; ask user to simplify the graph\n    showUserError('Unable to compute arrow geometry. Try simplifying the gitGraph or switching direction.');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Treat this error as a symptom of upstream layout corruption (NaN positions) and investigate error 60 first.","Keep gitGraph diagrams reasonably small to avoid geometry edge cases.","Pin a known-good mermaid version and test diagrams when upgrading."],"tags":["mermaid","gitgraph","rendering","geometry","internal-invariant"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}