apache/hadoop · error · IOException

Har: append not allowed.

Error message

Har: append not allowed.

What it means

The three-argument append(Path, int, Progressable) override throws 'Har: append not allowed' because har members are byte ranges inside immutable part files; appending would require rewriting archive internals. HarFileSystem supports only read operations.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:730

  }

  @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) {
      try {
        fs.close();
      } catch(IOException ie) {
        //this might already be closed
        // ignore
      }
    }
  }
  
  /**
   * Not implemented.
   */

View on GitHub (pinned to 2add963021)

Solutions

  1. Append to a regular file on the underlying HDFS and rebuild the archive when needed
  2. Move append-based data flows off har:// entirely — archives are for cold, immutable data
  3. Validate destination scheme before choosing the append code path

Example fix

// before
fs.append(new Path("har://hdfs-nn:8020/a/data.har/log.txt"), 4096, null);

// after
hdfs.append(new Path("hdfs://nn:8020/a/logs/log.txt"), 4096, null);
Defensive patterns

Strategy: validation

Validate before calling

if ("har".equals(dst.toUri().getScheme())) {
  throw new UnsupportedOperationException("append is not supported on har: " + dst);
}

Prevention

When it happens

Trigger: fs.append(harPath, bufferSize, progress) on any har:// path — e.g., append-style log writers, or copy utilities with an append flag that resolve their destination to the har filesystem.

Common situations: Log-aggregation or sink code configured with a har:// base path; tools that fall back to append when a destination file exists.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/79034d95e1b3588f. Report an issue: GitHub.