{"record":{"id":"4b8ca2cfcbdaa1b0","repo":"apache/hadoop","slug":"target-path-not-specified-target-path-src-path","errorCode":null,"errorMessage":"Target path not specified. <target path> <src path> <src path> ...","messagePattern":"Target path not specified\\. <target path> <src path> <src path> \\.\\.\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Concat.java","lineNumber":53,"sourceCode":"@InterfaceAudience.Private\n@InterfaceStability.Unstable\npublic class Concat extends FsCommand {\n  public static void registerCommands(CommandFactory factory) {\n    factory.addClass(Concat.class, \"-concat\");\n  }\n\n  public static final String NAME = \"concat\";\n  public static final String USAGE = \"<target path> <src path> <src path> ...\";\n  public static final String DESCRIPTION = \"Concatenate existing source files\"\n      + \" into the target file. Target file and source files should be in the\"\n      + \" same directory.\";\n  private static FileSystem testFs; // test only.\n\n  @Override\n  protected void processArguments(LinkedList<PathData> args)\n      throws IOException {\n    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));","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Concat.java#L35-L71","documentation":"Thrown by Concat.processArguments() (hdfs dfs concat) when zero arguments remain after option parsing. concat requires '<target path> <src path> <src path> ...' - i.e. a target file plus at least two source files - and fails fast with IOException('Target path not specified. <target path> <src path> <src path> ...') before touching the filesystem. concat delegates to FileSystem.concat(), which appends sources to the target; all files must be in the same directory with the same block/replication settings (HDFS only).","triggerScenarios":"'hdfs dfs concat' with no arguments; a script variable for the target expanding to empty; wrapping code that filters out the only argument before invoking.","commonSituations":"Automated HDFS-small-files compaction jobs parameterized by date where the target expression evaluates empty; invoking concat through a wrapper that mis-parses options.","solutions":["Supply the target path first followed by at least two source paths","Guard the shell call: [ -n \"$target\" ] || { echo 'target missing'; exit 1; }","Run 'hdfs dfs -help concat' to confirm the argument shape"],"exampleFix":"# before\nhdfs dfs concat\n# after\nhdfs dfs concat /data/target /data/part-0 /data/part-1","handlingStrategy":"validation","validationCode":"// wrapper guard before invoking concat\nif (args == null || args.length < 3) {\n  throw new IllegalArgumentException(\n    \"concat requires <target> plus at least 2 sources, got \"\n    + (args == null ? 0 : args.length));\n}","typeGuard":null,"tryCatchPattern":"try {\n  shellRun(concatArgs);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Target path not specified\")) {\n    throw new UsageException(\"usage: hdfs dfs concat <target path> <src path> <src path> ...\", e);\n  }\n  throw e;\n}","preventionTips":["Null/empty-check the target variable before building the command line","Centralize concat invocation behind a helper that enforces the argument shape","Remember concat is HDFS-only and same-directory only"],"tags":["hadoop","hdfs","concat","argument-validation","shell","java"],"backgroundTag":"missing-required-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}