{"record":{"id":"aa5f0990a4daa299","repo":"stanfordnlp/CoreNLP","slug":"error-invalid-dependency-node-line-line","errorCode":null,"errorMessage":"ERROR: Invalid dependency node line: ${line}","messagePattern":"ERROR: Invalid dependency node line: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/CustomAnnotationSerializer.java","lineNumber":67,"sourceCode":"  public CustomAnnotationSerializer() {\n    this(true, false);\n  }\n\n  public CustomAnnotationSerializer(boolean compress, boolean haveAnte) {\n    this.compress = compress;\n    this.haveExplicitAntecedent = haveAnte;\n  }\n\n\n  private static IntermediateSemanticGraph loadDependencyGraph(BufferedReader reader) throws IOException {\n    IntermediateSemanticGraph graph = new IntermediateSemanticGraph();\n\n    // first line: list of nodes\n    String line = reader.readLine().trim();\n    // System.out.println(\"PARSING LINE: \" + line);\n    if(line.length() > 0){\n      String [] bits = line.split(\"\\t\");\n      if(bits.length < 3) throw new RuntimeException(\"ERROR: Invalid dependency node line: \" + line);\n      String docId = bits[0];\n      if(docId.equals(\"-\")) docId = \"\";\n      int sentIndex = Integer.parseInt(bits[1]);\n      for(int i = 2; i < bits.length; i ++){\n        String bit = bits[i];\n        String[] bbits = bit.split(\"-\");\n        int copyAnnotation = -1;\n        boolean isRoot = false;\n        if(bbits.length > 3){\n          throw new RuntimeException(\"ERROR: Invalid format for dependency graph: \" + line);\n        } else if(bbits.length == 2){\n          copyAnnotation = Integer.parseInt(bbits[1]);\n        } else if(bbits.length == 3){\n          copyAnnotation = Integer.parseInt(bbits[1]);\n          isRoot = bbits[2].equals(\"R\");\n        }\n        int index = Integer.parseInt(bbits[0]);\n        graph.nodes.add(new IntermediateNode(docId, sentIndex, index, copyAnnotation, isRoot));","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/CustomAnnotationSerializer.java#L49-L85","documentation":"CustomAnnotationSerializer.loadDependencyGraph reads the first line of the dependency graph file as a tab-separated node list. Each line must have at least 3 tab-separated fields (docId, sentenceIndex, then one or more node entries). If the split yields fewer than 3 fields, the line is malformed and a RuntimeException is thrown.","triggerScenarios":"Loading a dependency graph file whose first non-empty line has fewer than 3 tab-separated fields — e.g. a truncated file, a corrupted serialized annotation, or a file written by a different/incompatible serializer.","commonSituations":"Manually editing dependency graph files and dropping a tab; passing a non-annotation file (e.g. plain text or a sentence-per-line file) to loadDependencyGraph; mixed CoreNLP versions where the serialization format changed.","solutions":["Regenerate the dependency graph file with CustomAnnotationSerializer from a pipeline run so the format is correct","Check the offending line has 3+ tab-separated fields: docId, sentence index, and node entries","Verify the file being loaded was produced by CustomAnnotationSerializer and not another format","Confirm consistent CoreNLP versions between writer and reader of the serialized data"],"exampleFix":"// before: passing arbitrary text file\nparser.loadDependencyGraph(new BufferedReader(new FileReader(\"tokens.txt\")));\n// after: pass a file produced by CustomAnnotationSerializer\nAnnotationSerializer serializer = new CustomAnnotationSerializer();\nPair<Annotation, InputStream> pair = serializer.read(new FileInputStream(\"serialized.ser.gz\"));","handlingStrategy":"validation","validationCode":"String line = reader.readLine().trim();\nint tabs = line.split(\"\\t\", -1).length;\nif (line.length() > 0 && tabs < 3) throw new IllegalArgumentException(\"Bad dependency node line: \" + line);","typeGuard":"static boolean isValidNodeLine(String line) {\n  return line == null || line.length() == 0 || line.split(\"\\t\", -1).length >= 3;\n}","tryCatchPattern":"try {\n  Pair<Annotation, InputStream> p = serializer.read(in);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"ERROR: Invalid dependency node line\")) {\n    // regenerate the serialized file\n  } else throw e;\n}","preventionTips":["Only load files produced by CustomAnnotationSerializer.write","Never hand-edit serialized dependency graph files","Pin CoreNLP versions across write/read of serialized annotations","Validate tab-field counts in a pre-flight check before deserializing"],"tags":["java","serialization","corenlp","dependency-graph","malformed-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}