apache/hadoop · error · IOException
Har: copyfromlocalfile not allowed
Error message
Har: copyfromlocalfile not allowed
What it means
The single-source copyFromLocalFile(boolean, boolean, Path, Path) override throws 'Har: copyfromlocalfile not allowed': uploading into a har would create new content, which the immutable archive forbids. Reads out of a har are supported (copyToLocalFile works), but writes in are not.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:833
public void setWorkingDirectory(Path newDir) {
//does nothing.
}
/**
* not implemented.
*/
@Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
throw new IOException("Har: mkdirs not allowed");
}
/**
* not implemented.
*/
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite,
Path src, Path dst) throws IOException {
throw new IOException("Har: copyfromlocalfile not allowed");
}
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite,
Path[] srcs, Path dst) throws IOException {
throw new IOException("Har: copyfromlocalfile not allowed");
}
/**
* copies the file in the har filesystem to a local file.
*/
@Override
public void copyToLocalFile(boolean delSrc, Path src, Path dst)
throws IOException {
FileUtil.copy(this, src, getLocal(getConf()), dst, false, getConf());
}
/**View on GitHub (pinned to 2add963021)
Solutions
- Upload to the underlying HDFS first (fs.copyFromLocalFile(..., hdfsDst)), then rebuild or create the archive with `hadoop archive`
- Update the script configuration so upload targets never use the har scheme
- For one-off additions: copy the archive's source tree, add the file, re-run `hadoop archive`
Example fix
// before
fs.copyFromLocalFile(false, false, new Path("/tmp/f.dat"), new Path("har://hdfs-nn:8020/a/data.har/f.dat"));
// after
hdfs.copyFromLocalFile(false, false, new Path("/tmp/f.dat"), new Path("/a/data/f.dat"));
// then: hadoop archive -archiveName data.har -p /a/data /a Defensive patterns
Strategy: validation
Validate before calling
if ("har".equals(dst.toUri().getScheme())) {
throw new UnsupportedOperationException("upload into har is not supported; upload to HDFS then run hadoop archive");
} Prevention
- Keep upload target configs on hdfs:// and treat har:// as read-only publication
- Add a scheme guard in shared upload utilities so all copyFromLocalFile variants are covered
When it happens
Trigger: fs.copyFromLocalFile(delSrc, overwrite, localSrc, harDst) with a har:// destination, directly or via FileUtil/FileSystem shell-style upload helpers.
Common situations: Ingestion scripts that push local files to a 'storage' URI later changed to har://; operators trying to add one file to an existing archive by uploading it in place.
Related errors
- Har: create not allowed.
- Har: append not allowed.
- Har: setReplication not allowed
- Har: rename not allowed
- Har: truncate not allowed
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/25134f9e7b3f9315.
Report an issue: GitHub.