{"record":{"id":"4b7abfc703aa857a","repo":"apache/hadoop","slug":"no-such-file-or-directory-4b7abf","errorCode":null,"errorMessage":"No such file or directory","messagePattern":"No such file or directory","errorType":"exception","errorClass":"PathNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java","lineNumber":268,"sourceCode":"        displayError(e);\n      }\n    }\n    return expandedArgs;\n  }\n\n  /**\n   * Expand the given argument into a list of {@link PathData} objects.\n   * The default behavior is to expand globs.  Commands may override to\n   * perform other expansions on an argument.\n   * @param arg string pattern to expand\n   * @return list of {@link PathData} objects\n   * @throws IOException if anything goes wrong...\n   */\n  protected List<PathData> expandArgument(String arg) throws IOException {\n    PathData[] items = PathData.expandAsGlob(arg, getConf());\n    if (items.length == 0) {\n      // it's a glob that failed to match\n      throw new PathNotFoundException(arg);\n    }\n    return Arrays.asList(items);\n  }\n\n  /**\n   *  Processes the command's list of expanded arguments.\n   *  {@link #processArgument(PathData)} will be invoked with each item\n   *  in the list.  The loop catches IOExceptions, increments the error\n   *  count, and displays the exception.\n   *  @param args a list of {@link PathData} to process\n   *  @throws IOException if anything goes wrong... \n   */\n  protected void processArguments(LinkedList<PathData> args)\n  throws IOException {\n    for (PathData arg : args) {\n      try {\n        processArgument(arg);\n      } catch (IOException e) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Command.java#L250-L286","documentation":"Command.expandArgument throws PathNotFoundException('No such file or directory') when PathData.expandAsGlob returns zero matches for an argument containing glob metacharacters. FsShell treats a matched-nothing glob as an error rather than an empty expansion, so the command aborts before processing.","triggerScenarios":"Any fs shell command with a non-matching glob: 'hadoop fs -ls \"sftp://host/*.tmp\"' when no such file exists, 'hadoop fs -rm /data/2026/08/*' before the daily partition has been written, or a glob whose scheme/authority is misspelled so nothing can match.","commonSituations":"Scheduled jobs whose glob targets date-partitioned data that has not landed yet; wrong authority or scheme in the glob; case-sensitivity mismatches in the pattern; globs written for a different cluster layout.","solutions":["Verify the pattern matches by listing its parent ('hadoop fs -ls /data/2026/08/') and adjust the expression.","In code, use FileSystem.globStatus(pattern) and branch on an empty result instead of letting a shell command fail.","Check the URI scheme and authority spelling in the glob; a wrong host can only ever match nothing."],"exampleFix":"# before\nhadoop fs -ls /data/2026/08/*.json   # throws when partition empty\n\n# after\nif hadoop fs -test -d /data/2026/08; then\n  hadoop fs -ls /data/2026/08/*.json || echo \"no .json files yet\"\nfi","handlingStrategy":"validation","validationCode":"FileStatus[] matches = fs.globStatus(pattern);\nif (matches == null || matches.length == 0) {\n  LOG.warn(\"glob matched nothing: {}\", pattern);\n  return; // or raise a domain-specific error\n}","typeGuard":null,"tryCatchPattern":"try {\n  runCommand(new String[]{\"-ls\", pattern});\n} catch (PathNotFoundException e) {\n  // glob matched nothing: data not landed yet or pattern wrong\n}","preventionTips":["Probe globs with globStatus() in code instead of failing in the shell.","Verify scheme and authority in glob patterns; wrong host guarantees zero matches.","For date-partitioned data, verify the partition directory exists before globbing its contents."],"tags":["cli","glob","path-not-found","hadoop","shell"],"backgroundTag":"glob-no-match","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}