{"record":{"id":"00e7ccc5393b5f2d","repo":"stanfordnlp/CoreNLP","slug":"error-reading-saved-links","errorCode":null,"errorMessage":"Error reading saved links","messagePattern":"Error reading saved links","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/misc/FromFileCorefAlgorithm.java","lineNumber":53,"sourceCode":"        String[] split = line.split(\"\\t\");\n        int did = Integer.valueOf(split[0]);\n\n        List<Pair<Integer, Integer>> docMerges = toMerge.get(did);\n        if (docMerges == null) {\n          docMerges = new ArrayList<>();\n          toMerge.put(did, docMerges);\n        }\n\n        if (split.length > 1) {\n          String[] pairs = split[1].split(\" \");\n          for (String pair : pairs) {\n            String[] ms = pair.split(\",\");\n            docMerges.add(new Pair<>(Integer.valueOf(ms[0]), Integer.valueOf(ms[1])));\n          }\n        }\n      });\n    } catch (IOException e) {\n      throw new RuntimeException(\"Error reading saved links\", e);\n    }\n  }\n\n  @Override\n  public void runCoref(Document document) {\n    if (toMerge.containsKey(currentDocId)) {\n      for (Pair<Integer, Integer> pair : toMerge.get(currentDocId)) {\n        CorefUtils.mergeCoreferenceClusters(pair, document);\n      }\n    }\n    currentDocId += 1;\n  }\n\n  public static void main(String[] args) throws Exception {\n    Properties props = StringUtils.argsToProperties(new String[] {\"-props\", args[0]});\n    new CorefSystem(new DocumentMaker(props, new Dictionaries(props)),\n        new FromFileCorefAlgorithm(args[1]), true, false).runOnConll(props);\n  }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/misc/FromFileCorefAlgorithm.java#L35-L71","documentation":"FromFileCorefAlgorithm reads gold coref merges from a file in its constructor and wraps any IOException in RuntimeException(\"Error reading saved links\"). It treats the merge-link file as mandatory input that must be readable.","triggerScenarios":"Constructing FromFileCorefAlgorithm when the file of saved coref links cannot be opened/read — missing file, wrong path, or unreadable contents (IOException from the readLines/consumer processing).","commonSituations":"Wrong value for the coref algorithm file property (typo or relative path resolved against unexpected working directory); file deleted or not packaged with the model distribution; running from a different CWD.","solutions":["Verify the path to the links file is correct and the file exists at runtime (print/resolve the path)","Run the JVM from a working directory where the relative path resolves correctly, or use an absolute path","Check file read permissions","Validate the file format (pairs like 'id1,id2' lines) — malformed content can also trigger the wrapped exception"],"exampleFix":"// before\nprops.setProperty(\"coref.algorithm.file\", \"links.txt\");\n// after\nFile f = new File(\"/abs/path/links.txt\");\nif (!f.canRead()) throw new IllegalArgumentException(\"links file missing: \" + f);\nprops.setProperty(\"coref.algorithm.file\", f.getAbsolutePath());","handlingStrategy":"validation","validationCode":"String linksPath = props.getProperty(\"coref.algorithm.file\", \"\");\njava.io.File f = new java.io.File(linksPath);\nif (linksPath.isEmpty() || !f.isFile() || !f.canRead())\n  throw new IllegalArgumentException(\"Coref links file not readable: \" + f.getAbsolutePath());","typeGuard":null,"tryCatchPattern":"try {\n  FromFileCorefAlgorithm algo = new FromFileCorefAlgorithm(props, dictionaries);\n} catch (RuntimeException e) {\n  if (\"Error reading saved links\".equals(e.getMessage()))\n    throw new IllegalStateException(\"Check coref links file path/contents\", e);\n  throw e;\n}","preventionTips":["Use absolute paths for the links file","Check file existence and readability at startup, before building the pipeline","Run the process from a known working directory or resolve paths programmatically","Validate the file format (integer,id pairs) before use"],"tags":["java","corenlp","io","file-read"],"backgroundTag":"file-read-failed","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"}