{"record":{"id":"b1dd036ef3603fc2","repo":"apache/hadoop","slug":"invalid-file-name-in","errorCode":null,"errorMessage":"Invalid file name: {} in {}","messagePattern":"Invalid file name: (.+?) in (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":652,"sourceCode":"   * index files. The permissions are not persisted \n   * while creating a hadoop archive.\n   * @param f the path in har filesystem\n   * @return filestatus.\n   * @throws IOException raised on errors performing I/O.\n   */\n  @Override\n  public FileStatus getFileStatus(Path f) throws IOException {\n    HarStatus hstatus = getFileHarStatus(f);\n    return toFileStatus(hstatus);\n  }\n\n  private HarStatus getFileHarStatus(Path f) throws IOException {\n    // get the fs DataInputStream for the underlying file\n    // look up the index.\n    Path p = makeQualified(f);\n    Path harPath = getPathInHar(p);\n    if (harPath == null) {\n      throw new IOException(\"Invalid file name: \" + f + \" in \" + uri);\n    }\n    HarStatus hstatus = metadata.archive.get(harPath);\n    if (hstatus == null) {\n      throw new FileNotFoundException(\"File: \" +  f + \" does not exist in \" + uri);\n    }\n    return hstatus;\n  }\n\n  @Override\n  public void msync() throws IOException, UnsupportedOperationException {\n    fs.msync();\n  }\n\n  /**\n   * @return null since no checksum algorithm is implemented.\n   */\n  @Override\n  public FileChecksum getFileChecksum(Path f, long length) {","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L634-L670","documentation":"getFileHarStatus translates the qualified path into an archive-relative path with getPathInHar (HarFileSystem.java:356-373), which walks up the directory chain until it hits archivePath (the ...har directory fixed at initialize). If it reaches the filesystem root '/' without ever matching, it returns null and this IOException is thrown: the requested path is not under this archive's directory at all.","triggerScenarios":"Calling getFileStatus, open, or exists (all routed through getFileHarStatus) with a path whose qualified form lacks the archive directory as an ancestor — e.g. omitting the /user/a/data.har segment, or using a path that belongs to a different archive or a sibling directory.","commonSituations":"Reusing one HarFileSystem instance with paths for another archive; dropping the .har directory segment from a stored path; code that qualifies relative paths against its own working directory before calling the har filesystem.","solutions":["Make the path fully qualified and include the archive directory, e.g. har://hdfs-nn:8020/user/a/data.har/dir/file","Verify the path starts with the same ...har directory as the URI the FileSystem was initialized with (fs.getWorkingDirectory() returns that archive root)","List the archive root with fs.listStatus(archiveUri) to confirm the namespace you are addressing"],"exampleFix":"// before\nFileSystem hfs = FileSystem.get(new URI(\"har://hdfs-nn:8020/user/a/data.har\"), conf);\nhfs.getFileStatus(new Path(\"har://hdfs-nn:8020/user/a/otherdir/file\")); // not under data.har\n\n// after\nhfs.getFileStatus(new Path(\"har://hdfs-nn:8020/user/a/data.har/file\"));","handlingStrategy":"validation","validationCode":"Path q = fs.makeQualified(path);\nString archiveRoot = fs.getWorkingDirectory().toUri().getPath(); // top-level ...har directory\nif (!q.toUri().getPath().startsWith(archiveRoot)) {\n  throw new IllegalArgumentException(path + \" is not under archive \" + archiveRoot);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.getFileStatus(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid file name\")) {\n    // path is outside this archive's namespace: fix the configured archive directory\n  }\n  throw e;\n}","preventionTips":["Always use fully qualified har:// paths that include the .har directory segment","Derive member paths from the same archive URI used to create the FileSystem (fs.getWorkingDirectory())","One HarFileSystem instance serves exactly one archive — never share it across archives"],"tags":["hadoop","har-filesystem","path-resolution","namespace"],"backgroundTag":"path-resolution-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}