{"record":{"id":"73a435f4779b9abd","repo":"apache/hadoop","slug":"neither-source-file-listing-nor-source-paths-prese","errorCode":null,"errorMessage":"Neither source file listing nor source paths present","messagePattern":"Neither source file listing nor source paths present","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java","lineNumber":282,"sourceCode":"\n    //Copy any source paths in the arguments to the list\n    for (int index = 0; index < leftOverArgs.length - 1; index++) {\n      sourcePaths.add(new Path(leftOverArgs[index].trim()));\n    }\n\n    /* If command has source file listing, use it else, fall back on source\n       paths in args.  If both are present, throw exception and bail */\n    if (command.hasOption(\n        DistCpOptionSwitch.SOURCE_FILE_LISTING.getSwitch())) {\n      if (!sourcePaths.isEmpty()) {\n        throw new IllegalArgumentException(\"Both source file listing and \" +\n            \"source paths present\");\n      }\n      return new DistCpOptions.Builder(new Path(getVal(command,\n          DistCpOptionSwitch.SOURCE_FILE_LISTING.getSwitch())), targetPath);\n    } else {\n      if (sourcePaths.isEmpty()) {\n        throw new IllegalArgumentException(\"Neither source file listing nor \" +\n            \"source paths present\");\n      }\n      return new DistCpOptions.Builder(sourcePaths, targetPath);\n    }\n  }\n\n  private static String getVal(CommandLine command, String swtch) {\n    if (swtch == null) {\n      return null;\n    }\n    String optionValue = command.getOptionValue(swtch.trim());\n    if (optionValue == null) {\n      return null;\n    } else {\n      return optionValue.trim();\n    }\n  }\n","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java#L264-L300","documentation":"The mirror case of the listing/paths conflict: no -f option was given AND the only positional argument was the target itself, so there are zero source paths. DistCp has nothing to copy and aborts during argument parsing.","triggerScenarios":"hadoop distcp hdfs://nn/tgt (single positional argument becomes the target, leaving no sources); hadoop distcp -update hdfs://nn/tgt.","commonSituations":"forgetting the source entirely; a script whose $SRC expanded to nothing so only the target token survived; operators reversing argument order confusion.","solutions":["Add at least one source path before the target: hadoop distcp <options> <src...> <target>.","Or use a file listing: hadoop distcp -f <listfile> <target>.","Echo the expanded command in the wrapper to catch empty source variables."],"exampleFix":"# before: only the target is present\nhadoop distcp hdfs://nn/tgt\n\n# after\nhadoop distcp hdfs://nn/src hdfs://nn/tgt","handlingStrategy":"validation","validationCode":"// Wrapper validation: without -f you need >= 2 positional args (source(s) + target)\nif (!hasF && positional.size() < 2) {\n  throw new IllegalArgumentException(\n      \"No sources given; usage: distcp <opts> <src...> <target> or -f <file> <target>\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  OptionsParser.parse(args);\n} catch (IllegalArgumentException e) {\n  if (\"Neither source file listing nor source paths present\".equals(e.getMessage())) {\n    throw new IllegalArgumentException(\"Add source path(s) or a -f listing\", e);\n  }\n  throw e;\n}","preventionTips":["Sanity-check that the command has at least two positional paths (or one plus -f).","Use shell nounset mode so an empty $SRC variable fails before distcp runs."],"tags":["distcp","cli","missing-argument","source-paths"],"backgroundTag":"missing-required-cli-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}