apache/hadoop · error · IOException

Unable to stat path: " + original

Error message

Unable to stat path: " + original

What it means

Thrown in Stat.parseExecResult when the executed 'stat' command produced no stdout at all (readLine() returns null). Hadoop expects at least one line of output - either a CSV record or an error string it can pattern-match - so empty output is treated as an unclassifiable failure and wrapped in IOException naming the original path.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java:117

          "stat", derefFlag + "c", "%s,%F,%Y,%X,%a,%U,%G,%N", path.toString() };
    } else if (Shell.FREEBSD || Shell.MAC) {
      return new String[] {
          "stat", derefFlag + "f", "%z,%HT,%m,%a,%Op,%Su,%Sg,`link' -> `%Y'",
          path.toString() };
    } else {
      throw new UnsupportedOperationException(
          "stat is not supported on this platform");
    }
  }

  @Override
  protected void parseExecResult(BufferedReader lines) throws IOException {
    // Reset stat
    stat = null;

    String line = lines.readLine();
    if (line == null) {
      throw new IOException("Unable to stat path: " + original);
    }
    if (line.endsWith("No such file or directory") ||
        line.endsWith("Not a directory")) {
      throw new FileNotFoundException("File " + original + " does not exist");
    }
    if (line.endsWith("Too many levels of symbolic links")) {
      throw new IOException("Possible cyclic loop while following symbolic" +
          " link " + original);
    }
    // 6,symbolic link,6,1373584236,1373584236,lrwxrwxrwx,andrew,andrew,`link' -> `target'
    // OR
    // 6,symbolic link,6,1373584236,1373584236,lrwxrwxrwx,andrew,andrew,'link' -> 'target'
    StringTokenizer tokens = new StringTokenizer(line, ",");
    try {
      long length = Long.parseLong(tokens.nextToken());
      boolean isDir = tokens.nextToken().equalsIgnoreCase("directory") ? true
          : false;
      // Convert from seconds to milliseconds

View on GitHub (pinned to 2add963021)

Solutions

  1. Run 'stat <path>' manually in the same environment and user to see what the command actually emits
  2. Check the process was not killed (dmesg/exit logs) and that PATH resolves the real GNU stat, not a shim
  3. Fall back to java.nio.file.Files.readAttributes for the FileStatus instead of the shell path
Defensive patterns

Strategy: try-catch

Try / catch

try {
  st = stat.getFileStatus();
} catch (IOException e) {
  // "Unable to stat path: X" -> stat produced no output at all
  // reproduce manually: stat <path>; check process limits and PATH shims
  throw e;
}

Prevention

When it happens

Trigger: The stat process died or was killed before writing output (OOM-killer, container limits), stdout was consumed/redirected by wrapper scripts, or the path string itself is empty/mangled so stat exits silently. Distinct from a normal 'No such file' case, which prints a line.

Common situations: Containers with aggressive process limits; environments where ShellCommandExecutor hooks or PATH shims swallow stdout; races where the filesystem is unmounted between process launch and output.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/5345dc1104b2fcb1. Report an issue: GitHub.