{"record":{"id":"6daa8d60dd5638f3","repo":"juicedata/juicefs","slug":"source-file-normalizepath-src","errorCode":null,"errorMessage":"Source file \" + normalizePath(src)\n                + \" is not in the same directory with the target \"\n                + normalizePath(dst)","messagePattern":"Source file \" \\+ normalizePath\\(src\\)\n                \\+ \" is not in the same directory with the target \"\n                \\+ normalizePath\\(dst\\)","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java","lineNumber":1612,"sourceCode":"  @Override\n  public void concat(final Path dst, final Path[] srcs) throws IOException {\n    if (needCheckPermission()) {\n      access(dst.getParent(), FsAction.WRITE);\n      access(dst, FsAction.WRITE);\n      for (Path src : srcs) {\n        access(src, FsAction.READ);\n      }\n      superGroupFileSystem.concat(dst, srcs);\n      return;\n    }\n    statistics.incrementWriteOps(1);\n    if (srcs.length == 0) {\n      throw new IllegalArgumentException(\"No sources given\");\n    }\n    Path dp = makeQualified(dst).getParent();\n    for (Path src : srcs) {\n      if (!makeQualified(src).getParent().equals(dp)) {\n        throw new HadoopIllegalArgumentException(\"Source file \" + normalizePath(src)\n                + \" is not in the same directory with the target \"\n                + normalizePath(dst));\n      }\n    }\n    byte[][] srcbytes = new byte[srcs.length][];\n    int bufsize = 0;\n    for (int i = 0; i < srcs.length; i++) {\n      srcbytes[i] = normalizePath(srcs[i]).getBytes(\"UTF-8\");\n      bufsize += srcbytes[i].length + 1;\n    }\n    Pointer buf = Memory.allocate(Runtime.getRuntime(lib), bufsize);\n    long offset = 0;\n    for (int i = 0; i < srcs.length; i++) {\n      buf.put(offset, srcbytes[i], 0, srcbytes[i].length);\n      buf.putByte(offset + srcbytes[i].length, (byte) 0);\n      offset += srcbytes[i].length + 1;\n    }\n    int r = lib.jfs_concat(Thread.currentThread().getId(), handle, normalizePath(dst), buf, bufsize);","sourceCodeStart":1594,"sourceCodeEnd":1630,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java#L1594-L1630","documentation":"Thrown by concat() when a source path is not in the same parent directory as the destination. JuiceFS's native concat requires all files in the same directory, so the wrapper pre-validates each src's parent against dst's parent and rejects mismatches with HadoopIllegalArgumentException.","triggerScenarios":"concat(dst, src) where src lives in a different directory than dst; using relative paths resolved differently from the qualified dst; programmatically mixing paths from multiple directories.","commonSituations":"Merging part files spread across subdirectories; users expecting HDFS-like cross-directory concat; staging files in /tmp then concatenating into a final directory.","solutions":["Move/copy the source files into the destination directory before concat","Choose a dst in the same directory as the sources","Rename sources to the target directory via fs.rename before concatenating","Batch sources per-directory and run one concat per directory"],"exampleFix":"// before\nfs.concat(new Path(\"/data/out/final\"), new Path[]{new Path(\"/tmp/part-0\")});\n// after\nfs.rename(new Path(\"/tmp/part-0\"), new Path(\"/data/out/part-0\"));\nfs.concat(new Path(\"/data/out/final\"), new Path[]{new Path(\"/data/out/part-0\")});","handlingStrategy":"validation","validationCode":"Path dp = dst.getParent(); for (Path s : srcs) if (!s.getParent().equals(dp)) throw new IllegalArgumentException(\"source not in dst dir: \" + s);","typeGuard":"boolean sameDir(Path dst, Path src) { return dst.getParent().equals(src.getParent()); }","tryCatchPattern":"try { fs.concat(dst, srcs); } catch (HadoopIllegalArgumentException e) { /* relocate sources then retry */ }","preventionTips":["Qualify all paths with makeQualified before comparing parents","Group files by directory before merging","Rename cross-directory sources into the destination first"],"tags":["java","hadoop","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}