{"record":{"id":"d7f1ddfc86ecdfc6","repo":"apache/hadoop","slug":"har-mkdirs-not-allowed","errorCode":null,"errorMessage":"Har: mkdirs not allowed","messagePattern":"Har: mkdirs not allowed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":824,"sourceCode":"  /**\n   * return the top level archive path.\n   */\n  @Override\n  public Path getHomeDirectory() {\n    return new Path(uri.toString());\n  }\n\n  @Override\n  public void setWorkingDirectory(Path newDir) {\n    //does nothing.\n  }\n  \n  /**\n   * not implemented.\n   */\n  @Override\n  public boolean mkdirs(Path f, FsPermission permission) throws IOException {\n    throw new IOException(\"Har: mkdirs not allowed\");\n  }\n  \n  /**\n   * not implemented.\n   */\n  @Override\n  public void copyFromLocalFile(boolean delSrc, boolean overwrite,\n      Path src, Path dst) throws IOException {\n    throw new IOException(\"Har: copyfromlocalfile not allowed\");\n  }\n\n  @Override\n  public void copyFromLocalFile(boolean delSrc, boolean overwrite,\n      Path[] srcs, Path dst) throws IOException {\n    throw new IOException(\"Har: copyfromlocalfile not allowed\");\n  }\n\n  /**","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L806-L842","documentation":"mkdirs throws 'Har: mkdirs not allowed' because a har has no writable namespace: directories exist only as index entries created by the archive tool. Any attempt to create directories inside har:// fails unconditionally.","triggerScenarios":"fs.mkdirs(harPath) — typically job setup that pre-creates output directories, or copy utilities that ensure the destination directory exists before writing.","commonSituations":"Frameworks whose setup step is `if (!fs.exists(outDir)) fs.mkdirs(outDir)` receiving a har:// output path; deployment scripts preparing directory trees across mixed filesystems.","solutions":["Create directories on the underlying HDFS before running `hadoop archive`, not after","Point output-directory configuration at a writable filesystem (hdfs://)","Make 'ensure directory exists' helpers tolerate read-only filesystems instead of calling mkdirs blindly"],"exampleFix":"// before\nif (!fs.exists(outDir)) { fs.mkdirs(outDir); } // outDir is har://\n\n// after\nif (\"har\".equals(outDir.toUri().getScheme())) {\n  throw new IllegalArgumentException(\"cannot create directories under read-only \" + outDir);\n}\nif (!fs.exists(outDir)) { fs.mkdirs(outDir); }","handlingStrategy":"validation","validationCode":"if (\"har\".equals(outDir.toUri().getScheme())) {\n  throw new UnsupportedOperationException(\"cannot mkdirs under read-only har: \" + outDir);\n}\nif (!fs.exists(outDir)) { fs.mkdirs(outDir); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate output-directory schemes in job setup before any mkdirs call","Make 'ensure dir exists' helpers read-only-aware instead of calling mkdirs unconditionally"],"tags":["hadoop","har-filesystem","read-only","mkdirs"],"backgroundTag":"read-only-filesystem-write","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}