{"record":{"id":"157a626a03e23bc8","repo":"apache/hadoop","slug":"har-create-not-allowed","errorCode":null,"errorMessage":"Har: create not allowed.","messagePattern":"Har: create 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":718,"sourceCode":"  public FSDataInputStream open(PathHandle fd, int bufferSize)\n      throws IOException {\n    throw new UnsupportedOperationException();\n  }\n\n  /**\n   * Used for delegation token related functionality. Must delegate to\n   * underlying file system.\n   */\n  @Override\n  public FileSystem[] getChildFileSystems() {\n    return new FileSystem[]{fs};\n  }\n\n  @Override\n  public FSDataOutputStream create(Path f, FsPermission permission,\n      boolean overwrite, int bufferSize, short replication, long blockSize,\n      Progressable progress) throws IOException {\n    throw new IOException(\"Har: create not allowed.\");\n  }\n\n  @Override\n  public FSDataOutputStream createNonRecursive(Path f, boolean overwrite,\n      int bufferSize, short replication, long blockSize, Progressable progress)\n      throws IOException {\n    throw new IOException(\"Har: create not allowed.\");\n  }\n\n  @Override\n  public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {\n    throw new IOException(\"Har: append not allowed.\");\n  }\n\n  @Override\n  public void close() throws IOException {\n    super.close();\n    if (fs != null) {","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L700-L736","documentation":"HarFileSystem is a read-only view: a .har is an immutable package (index + part files) produced by the `hadoop archive` tool, and every mutating FileSystem API is overridden to throw. FileSystem.create(...) throws 'Har: create not allowed' — new files cannot be written into an archive.","triggerScenarios":"fs.create(new Path(\"har://...\")) directly, or any framework opening an output stream on an output path under har://: MapReduce/Spark output committers, Hive/Spark INSERT writes, DistCp with a har:// destination.","commonSituations":"Setting mapreduce.output.fileoutputformat.outputdir, a Spark write path, or a Hive staging location to har://; generic copy utilities that write to whatever filesystem the destination URI resolves to.","solutions":["Write to the underlying filesystem (hdfs://...) instead, then package with `hadoop archive -archiveName out.har -p <dir> <parentDir>`","Fix the configuration: output, staging, and temp directories must never use the har scheme","To expose new data as har, write to HDFS, build a fresh .har, and publish its har:// URI"],"exampleFix":"// before\nFSDataOutputStream out = fs.create(new Path(\"har://hdfs-nn:8020/a/data.har/newFile\"));\n\n// after\nFSDataOutputStream out = hdfs.create(new Path(\"hdfs://nn:8020/a/data/newFile\"));\n// then: hadoop archive -archiveName data.har -p /a/data /a","handlingStrategy":"validation","validationCode":"static void requireWritablePath(Path p) {\n  URI u = p.toUri();\n  if (\"har\".equals(u.getScheme())) {\n    throw new UnsupportedOperationException(\"har:// is read-only; write to the underlying filesystem instead: \" + p);\n  }\n}","typeGuard":"static boolean isReadOnlyHarFs(FileSystem fs) {\n  return fs instanceof HarFileSystem;\n}","tryCatchPattern":null,"preventionTips":["Validate the scheme of every output/staging directory at job-assembly time","Keep a single factory that rejects har destinations for all write APIs (create, append, rename, delete, mkdirs)","Document in ops runbooks that `hadoop archive` is the only supported writer for .har"],"tags":["hadoop","har-filesystem","read-only","create","output-stream"],"backgroundTag":"read-only-filesystem-write","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}