{"record":{"id":"fd89c82483a463e1","repo":"stanfordnlp/CoreNLP","slug":"directory-access-problem-for-path-fd89c8","errorCode":null,"errorMessage":"Directory access problem for: ${path}","messagePattern":"Directory access problem for: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/FilePathProcessor.java","lineNumber":76,"sourceCode":"   * filter are processed.  If the <code>path</code>is a file, then\n   * that file is processed regardless of whether it satisfies the\n   * filter.  (This semantics was adopted, since otherwise there was no\n   * easy way to go through all the files in a directory without\n   * descending recursively via the specification of a\n   * <code>FileFilter</code>.)\n   *\n   * @param path      file or directory to load from\n   * @param filter    a FileFilter of files to load.  The filter may be null,\n   *     and then all files are processed.\n   * @param processor The <code>FileProcessor</code> to apply to each\n   *                  <code>File</code>\n   */\n  public static void processPath(File path, FileFilter filter, FileProcessor processor) {\n    if (path.isDirectory()) {\n      // if path is a directory, look into it\n      File[] directoryListing = path.listFiles(filter);\n      if (directoryListing == null) {\n        throw new IllegalArgumentException(\"Directory access problem for: \" + path);\n      }\n      for (File file : directoryListing) {\n        processPath(file, filter, processor);\n      }\n    } else {\n      // it's already passed the filter or was uniquely specified\n      // if (filter.accept(path))\n      processor.processFile(path);\n    }\n  }\n\n}\n","sourceCodeStart":58,"sourceCodeEnd":89,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/FilePathProcessor.java#L58-L89","documentation":"FilePathProcessor.processPath throws IllegalArgumentException when File.listFiles(filter) returns null on a directory, which the JVM does when the directory cannot be read (I/O error or access denied). It surfaces a filesystem access problem while recursively processing a path.","triggerScenarios":"Calling processPath on a directory the process lacks read permission for, a directory that vanished mid-walk, or an I/O error during listing.","commonSituations":"Running on paths owned by another user; restricted sandboxes/containers; walking system directories; race where the directory is deleted during traversal.","solutions":["Check canRead() on the path before processing and skip/report unreadable directories.","Run the process with sufficient filesystem permissions, or use a user with access to the target tree.","Verify the directory exists and is not concurrently deleted; handle races defensively.","Catch IllegalArgumentException around processPath and log/skip the offending path instead of aborting the whole walk."],"exampleFix":"// before\nFilePathProcessor.processPath(new File(\"/root/secure\"), filter, proc);\n// after\nFile dir = new File(\"/root/secure\");\nif (dir.isDirectory() && dir.canRead()) {\n  FilePathProcessor.processPath(dir, filter, proc);\n} else {\n  log.warn(\"Skipping unreadable directory: \" + dir);\n}","handlingStrategy":"try-catch","validationCode":"if (path.isDirectory() && !path.canRead()) { log.warn(\"Skipping unreadable: \" + path); return; }","typeGuard":"boolean isReadableDirectory(File f) { return f != null && f.isDirectory() && f.canRead(); }","tryCatchPattern":"try { FilePathProcessor.processPath(dir, filter, proc); } catch (IllegalArgumentException e) { log.warn(\"Skipping: \" + e.getMessage()); }","preventionTips":["Check canRead() before walking directories","Run with a user that has read access to the target tree","Handle paths deleted mid-traversal defensively","Skip-and-log unreadable entries instead of aborting whole walks"],"tags":["java","filesystem","permissions","io"],"backgroundTag":"permission-denied","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"}