{"record":{"id":"5345dc1104b2fcb1","repo":"apache/hadoop","slug":"unable-to-stat-path-original","errorCode":null,"errorMessage":"Unable to stat path: \" + original","messagePattern":"Unable to stat path: \" \\+ original","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java","lineNumber":117,"sourceCode":"          \"stat\", derefFlag + \"c\", \"%s,%F,%Y,%X,%a,%U,%G,%N\", path.toString() };\n    } else if (Shell.FREEBSD || Shell.MAC) {\n      return new String[] {\n          \"stat\", derefFlag + \"f\", \"%z,%HT,%m,%a,%Op,%Su,%Sg,`link' -> `%Y'\",\n          path.toString() };\n    } else {\n      throw new UnsupportedOperationException(\n          \"stat is not supported on this platform\");\n    }\n  }\n\n  @Override\n  protected void parseExecResult(BufferedReader lines) throws IOException {\n    // Reset stat\n    stat = null;\n\n    String line = lines.readLine();\n    if (line == null) {\n      throw new IOException(\"Unable to stat path: \" + original);\n    }\n    if (line.endsWith(\"No such file or directory\") ||\n        line.endsWith(\"Not a directory\")) {\n      throw new FileNotFoundException(\"File \" + original + \" does not exist\");\n    }\n    if (line.endsWith(\"Too many levels of symbolic links\")) {\n      throw new IOException(\"Possible cyclic loop while following symbolic\" +\n          \" link \" + original);\n    }\n    // 6,symbolic link,6,1373584236,1373584236,lrwxrwxrwx,andrew,andrew,`link' -> `target'\n    // OR\n    // 6,symbolic link,6,1373584236,1373584236,lrwxrwxrwx,andrew,andrew,'link' -> 'target'\n    StringTokenizer tokens = new StringTokenizer(line, \",\");\n    try {\n      long length = Long.parseLong(tokens.nextToken());\n      boolean isDir = tokens.nextToken().equalsIgnoreCase(\"directory\") ? true\n          : false;\n      // Convert from seconds to milliseconds","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run 'stat <path>' manually in the same environment and user to see what the command actually emits","Check the process was not killed (dmesg/exit logs) and that PATH resolves the real GNU stat, not a shim","Fall back to java.nio.file.Files.readAttributes for the FileStatus instead of the shell path"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  st = stat.getFileStatus();\n} catch (IOException e) {\n  // \"Unable to stat path: X\" -> stat produced no output at all\n  // reproduce manually: stat <path>; check process limits and PATH shims\n  throw e;\n}","preventionTips":["Smoke-test 'stat' availability and output in deployment environments before relying on Stat","Prefer NIO-based attribute reads over shelling out where possible"],"tags":["hadoop","stat","shell-command","empty-output"],"backgroundTag":"shell-command-output-parse","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}