{"record":{"id":"6e36137540477958","repo":"stanfordnlp/CoreNLP","slug":"error-invalid-format-for-dependency-graph-line","errorCode":null,"errorMessage":"ERROR: Invalid format for dependency graph: ${line}","messagePattern":"ERROR: Invalid format for dependency graph: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/CustomAnnotationSerializer.java","lineNumber":77,"sourceCode":"  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));\n      }\n    }\n\n    // second line: list of deps\n    line = reader.readLine().trim();\n    if(line.length() > 0){\n      String [] bits = line.split(\"\\t\");\n      for(String bit: bits){\n        String [] bbits = bit.split(\" \");\n        if(bbits.length < 3 || bbits.length > 6){","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/CustomAnnotationSerializer.java#L59-L95","documentation":"Within loadDependencyGraph, each node entry (after docId and sentence index) is a token split on '-' with at most 3 parts (id, copy annotation, optional root flag 'R'). If a node entry splits into more than 3 parts, the entry format is invalid and a RuntimeException is thrown.","triggerScenarios":"A node entry in the dependency graph's node line contains more than two '-' characters, e.g. a token id accidentally containing hyphens or a hand-edited/corrupted node entry.","commonSituations":"Hand-editing serialized dependency files; tokens whose serialized representation embeds '-' separators incorrectly; writing the graph with a custom formatter that deviates from the expected id-copyBits convention.","solutions":["Fix the offending node entry so each is of form id, id-copyNum, or id-copyNum-R","Regenerate the file with CustomAnnotationSerializer.write instead of manual editing","Check for accidental extra hyphens in node ids in the input line","Validate one line at a time with a small script splitting on tab then '-' before loading"],"exampleFix":"// before: line contains bad entry like \"5-2-extra\"\n// 5\t0\t3-1\t5-2-extra\n// after: corrected node entries with valid id-copy[-R] form\n// 5\t0\t3-1\t5-2-R","handlingStrategy":"validation","validationCode":"for (String entry : nodeFields) {\n  int hyphens = entry.length() - entry.replace(\"-\", \"\").length();\n  if (hyphens > 2) throw new IllegalArgumentException(\"Bad node entry: \" + entry);\n}","typeGuard":"static boolean isValidNodeEntry(String entry) {\n  String[] bbits = entry.split(\"-\", -1);\n  return bbits.length >= 1 && bbits.length <= 3;\n}","tryCatchPattern":"try {\n  serializer.read(in);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"ERROR: Invalid format for dependency graph\")) {\n    log.severe(\"Corrupt node entry; regenerate file\");\n  } else throw e;\n}","preventionTips":["Keep node ids free of '-' separators","Regenerate files with the serializer rather than editing them by hand","Validate id-copy[-R] format of node entries before loading","Use consistent CoreNLP versions for writing and reading"],"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"}