{"record":{"id":"7ca80808f73b3b4d","repo":"mermaid-js/mermaid","slug":"line-origlineno-empty-node-expected-a-filena","errorCode":null,"errorMessage":"Line ${origLineNo}: Empty node — expected a filename or directory name after the box-drawing prefix","messagePattern":"Line (.+?): Empty node — expected a filename or directory name after the box-drawing prefix","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/treeView/boxDrawingPreprocessor.ts","lineNumber":176,"sourceCode":"    const branchMatch = BRANCH_CHAR.exec(normalized);\n\n    if (branchMatch?.index !== undefined) {\n      // Has branch char → compute depth from column position\n      const branchCol = branchMatch.index;\n      const depth = Math.round(branchCol / segmentWidth) + 1;\n\n      // Extract content: skip branch char, then dashes, then spaces\n      let pos = branchCol + 1;\n      while (pos < normalized.length && DASH_CHAR.test(normalized[pos])) {\n        pos++;\n      }\n      while (pos < normalized.length && normalized[pos] === ' ') {\n        pos++;\n      }\n      const content = normalized.slice(pos).trimEnd();\n\n      if (!content) {\n        throw new Error(\n          `Line ${origLineNo}: Empty node — expected a filename or directory name after the box-drawing prefix`\n        );\n      }\n\n      const indent = INDENT_UNIT.repeat(depth);\n      outputLines.push(indent + content);\n      outLineNo++;\n      lineMap.set(outLineNo, origLineNo);\n    } else if (/^[\\s─━│┃└┗├┣]+$/.test(normalized)) {\n      // Entire line is box-drawing decoration and whitespace — skip\n      continue;\n    } else if (ALL_BOX_CHARS.test(normalized)) {\n      // Has box chars but no branch char — likely content containing a box char (e.g. \"Section ─ A.txt\")\n      // Treat as root-level item\n      outputLines.push(line);\n      outLineNo++;\n      lineMap.set(outLineNo, origLineNo);\n    } else if (/^\\s+/.test(normalized)) {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/treeView/boxDrawingPreprocessor.ts#L158-L194","documentation":"The treeView box-drawing preprocessor converts ASCII-tree input into indented text. After a branch character (├/└), the following dashes and spaces are skipped; whatever remains is the node name. If nothing remains, the line is a branch prefix with no content, so the input is rejected with the original line number.","triggerScenarios":"A line in box-drawing mode containing only a branch glyph and connectors/spaces, e.g. `├──` or `└──   ` with no filename/directory after it.","commonSituations":"Trailing branch line from a copy-paste of `tree` output where the last entry was trimmed; manual editing that left an empty child; generated trees emitting a connector for a removed node; trailing whitespace mistaken for content.","solutions":["Add the missing filename/directory name after the branch prefix on the reported line.","Delete the empty branch line if no node is intended.","Regenerate the tree source so every ├──/└── has a following name.","Trim trailing decoration-only lines before parsing."],"exampleFix":"// before\n├── src\n└──\n\n// after\n├── src\n└── dist","handlingStrategy":"validation","validationCode":"// Reject branch lines with no node content before feeding mermaid\nfor (let i = 0; i < lines.length; i++) {\n  if (/^[│┃ ]*[├└┗]/.test(lines[i])) {\n    const after = lines[i].replace(/^[│┃ ]*[├└┗]+[-─━ ]*/, '');\n    if (!after.trim()) throw new Error(`Line ${i + 1}: empty node`);\n  }\n}","typeGuard":"const isEmptyNodeError = (e): boolean =>\n  e instanceof Error && /Empty node/.test(e.message);","tryCatchPattern":"try {\n  await mermaid.run({ nodes: [el] });\n} catch (e) {\n  if (e instanceof Error && /Empty node/.test(e.message)) {\n    // parse the line number from the message and add a name or drop the line\n  } else { throw e; }\n}","preventionTips":["Ensure every ├──/└── line is followed by a node name.","Trim trailing connector-only lines from tree sources.","Regenerate trees from the filesystem rather than hand-editing."],"tags":["treeview","box-drawing","preprocessor","empty-node","validation"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}