apache/hadoop · error · IOException
Har: create not allowed.
Error message
Har: create not allowed.
What it means
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.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:718
public FSDataInputStream open(PathHandle fd, int bufferSize)
throws IOException {
throw new UnsupportedOperationException();
}
/**
* Used for delegation token related functionality. Must delegate to
* underlying file system.
*/
@Override
public FileSystem[] getChildFileSystems() {
return new FileSystem[]{fs};
}
@Override
public FSDataOutputStream create(Path f, FsPermission permission,
boolean overwrite, int bufferSize, short replication, long blockSize,
Progressable progress) throws IOException {
throw new IOException("Har: create not allowed.");
}
@Override
public FSDataOutputStream createNonRecursive(Path f, boolean overwrite,
int bufferSize, short replication, long blockSize, Progressable progress)
throws IOException {
throw new IOException("Har: create not allowed.");
}
@Override
public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException {
throw new IOException("Har: append not allowed.");
}
@Override
public void close() throws IOException {
super.close();
if (fs != null) {View on GitHub (pinned to 2add963021)
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
Example fix
// before
FSDataOutputStream out = fs.create(new Path("har://hdfs-nn:8020/a/data.har/newFile"));
// after
FSDataOutputStream out = hdfs.create(new Path("hdfs://nn:8020/a/data/newFile"));
// then: hadoop archive -archiveName data.har -p /a/data /a Defensive patterns
Strategy: validation
Validate before calling
static void requireWritablePath(Path p) {
URI u = p.toUri();
if ("har".equals(u.getScheme())) {
throw new UnsupportedOperationException("har:// is read-only; write to the underlying filesystem instead: " + p);
}
} Type guard
static boolean isReadOnlyHarFs(FileSystem fs) {
return fs instanceof HarFileSystem;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Har: append not allowed.
- Har: setReplication not allowed
- Har: rename not allowed
- Har: truncate not allowed
- Har: delete not allowed
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/157a626a03e23bc8.
Report an issue: GitHub.