apache/hadoop · error · IOException

Target path not specified. <target path> <src path> <src pat

Error message

Target path not specified. <target path> <src path> <src path> ...

What it means

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).

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Concat.java:53

@InterfaceAudience.Private
@InterfaceStability.Unstable
public class Concat extends FsCommand {
  public static void registerCommands(CommandFactory factory) {
    factory.addClass(Concat.class, "-concat");
  }

  public static final String NAME = "concat";
  public static final String USAGE = "<target path> <src path> <src path> ...";
  public static final String DESCRIPTION = "Concatenate existing source files"
      + " into the target file. Target file and source files should be in the"
      + " same directory.";
  private static FileSystem testFs; // test only.

  @Override
  protected void processArguments(LinkedList<PathData> args)
      throws IOException {
    if (args.size() < 1) {
      throw new IOException("Target path not specified. " + USAGE);
    }
    if (args.size() < 3) {
      throw new IOException(
          "The number of source paths is less than 2. " + USAGE);
    }
    PathData target = args.removeFirst();
    LinkedList<PathData> srcList = args;
    if (!target.exists || !target.stat.isFile()) {
      throw new FileNotFoundException(String
          .format("Target path %s does not exist or is" + " not file.",
              target.path));
    }
    Path[] srcArray = new Path[srcList.size()];
    for (int i = 0; i < args.size(); i++) {
      PathData src = srcList.get(i);
      if (!src.exists || !src.stat.isFile()) {
        throw new FileNotFoundException(
            String.format("%s does not exist or is not file.", src.path));

View on GitHub (pinned to 2add963021)

Solutions

  1. Supply the target path first followed by at least two source paths
  2. Guard the shell call: [ -n "$target" ] || { echo 'target missing'; exit 1; }
  3. Run 'hdfs dfs -help concat' to confirm the argument shape

Example fix

# before
hdfs dfs concat
# after
hdfs dfs concat /data/target /data/part-0 /data/part-1
Defensive patterns

Strategy: validation

Validate before calling

// wrapper guard before invoking concat
if (args == null || args.length < 3) {
  throw new IllegalArgumentException(
    "concat requires <target> plus at least 2 sources, got "
    + (args == null ? 0 : args.length));
}

Try / catch

try {
  shellRun(concatArgs);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Target path not specified")) {
    throw new UsageException("usage: hdfs dfs concat <target path> <src path> <src path> ...", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: '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.

Common situations: Automated HDFS-small-files compaction jobs parameterized by date where the target expression evaluates empty; invoking concat through a wrapper that mis-parses options.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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