{"record":{"id":"8f130988a1dce719","repo":"apache/hadoop","slug":"s-does-not-exist-or-is-not-file","errorCode":null,"errorMessage":"%s does not exist or is not file.","messagePattern":"(.+?) does not exist or is not file\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Concat.java","lineNumber":70,"sourceCode":"    if (args.size() < 1) {\n      throw new IOException(\"Target path not specified. \" + USAGE);\n    }\n    if (args.size() < 3) {\n      throw new IOException(\n          \"The number of source paths is less than 2. \" + USAGE);\n    }\n    PathData target = args.removeFirst();\n    LinkedList<PathData> srcList = args;\n    if (!target.exists || !target.stat.isFile()) {\n      throw new FileNotFoundException(String\n          .format(\"Target path %s does not exist or is\" + \" not file.\",\n              target.path));\n    }\n    Path[] srcArray = new Path[srcList.size()];\n    for (int i = 0; i < args.size(); i++) {\n      PathData src = srcList.get(i);\n      if (!src.exists || !src.stat.isFile()) {\n        throw new FileNotFoundException(\n            String.format(\"%s does not exist or is not file.\", src.path));\n      }\n      srcArray[i] = src.path;\n    }\n    FileSystem fs = target.fs;\n    if (testFs != null) {\n      fs = testFs;\n    }\n    try {\n      fs.concat(target.path, srcArray);\n    } catch (UnsupportedOperationException exception) {\n      throw new PathIOException(\"Dest filesystem '\" + fs.getUri().getScheme()\n          + \"' doesn't support concat.\", exception);\n    }\n  }\n\n  @VisibleForTesting\n  static void setTestFs(FileSystem fs) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Concat.java#L52-L88","documentation":"Thrown by the 'hadoop fs -concat' command (Concat.java:70) during argument pre-validation: one of the SOURCE paths passed after the target does not exist on the filesystem, or exists but is not a regular file (e.g. a directory). Concat only merges existing regular files into an existing target file in the same directory, so every src path is checked with PathData.exists and stat.isFile() before FileSystem.concat() is called.","triggerScenarios":"Running 'hdfs dfs -concat /dir/target /dir/src1 /dir/src2' where any src path has a typo, was deleted/renamed by a concurrent job between listing and concat, is a directory, or is an empty glob expansion. The failure occurs before any block merge is attempted.","commonSituations":"Typos in generated shell scripts that build the src list dynamically; a MapReduce/Spark job renaming part files after the script listed them; passing a directory or a glob like '/data/part-*' that matched nothing; src paths that resolve on a different filesystem than the target.","solutions":["Verify every source exists and is a file before running the command: 'hdfs dfs -ls /data/part-*' or in code fs.getFileStatus(src).isFile()","Fix the typo'd or stale path in the command / script that assembles the src list","If the source is a directory, list its files and pass them explicitly, or use 'hadoop fs -getmerge' instead (it reads contents rather than merging blocks)","Ensure all src paths and the target are on the same filesystem and, per the command contract, in the same directory"],"exampleFix":"# before\nhdfs dfs -concat /data/target /data/part-000 /data/part-999   # part-999 does not exist\n\n# after\nhdfs dfs -ls /data/part-*    # confirm each source exists and is a regular file\nhdfs dfs -concat /data/target /data/part-000 /data/part-001","handlingStrategy":"validation","validationCode":"FileSystem fs = targetPath.getFileSystem(conf);\nfor (Path src : srcPaths) {\n  if (!fs.exists(src) || !fs.getFileStatus(src).isFile()) {\n    throw new FileNotFoundException(src + \" does not exist or is not file.\");\n  }\n}","typeGuard":"static boolean isExistingRegularFile(FileSystem fs, Path p) throws IOException {\n  return fs.exists(p) && fs.getFileStatus(p).isFile();\n}","tryCatchPattern":"try {\n  fs.concat(target, srcs);\n} catch (FileNotFoundException e) {\n  // message names the offending src path; re-validate and report which source vanished\n}","preventionTips":["Validate every src with exists()+isFile() before invoking concat","Build the src list and run concat in one step to shrink the race window with concurrent renames","Keep target and all sources in the same directory and on the same filesystem scheme"],"tags":["hadoop","hdfs","filesystem","shell","concat","file-not-found","argument-validation"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}