apache/hadoop · error · UnsupportedOperationException

getErasureCodingPolicy is not supported for HttpFs on {0}. P

Error message

getErasureCodingPolicy is not supported for HttpFs on {0}. Please check your fs.defaultFS configuration

What it means

FSOperations.FSGetErasureCodingPolicy.execute() resolves GETERASURECODINGPOLICY only through DistributedFileSystem.getErasureCodingPolicy(path); erasure coding state is meaningless outside HDFS, so the executor throws UnsupportedOperationException for any other backing filesystem (HTTP 400 at the REST layer).

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java:2156

   */
  @InterfaceAudience.Private
  public static class FSGetErasureCodingPolicy
      implements FileSystemAccess.FileSystemExecutor<String> {

    private Path path;

    public FSGetErasureCodingPolicy(String path) {
      this.path = new Path(path);
    }

    @Override
    public String execute(FileSystem fs) throws IOException {
      ErasureCodingPolicy policy = null;
      if (fs instanceof DistributedFileSystem) {
        DistributedFileSystem dfs = (DistributedFileSystem) fs;
        policy = dfs.getErasureCodingPolicy(path);
      } else {
        throw new UnsupportedOperationException("getErasureCodingPolicy is "
            + "not supported for HttpFs on " + fs.getClass()
            + ". Please check your fs.defaultFS configuration");
      }
      return JsonUtil.toJsonString(policy);
    }
  }

  /**
   * Executor that performs a unsetErasureCodingPolicy operation.
   */
  @InterfaceAudience.Private
  public static class FSUnSetErasureCodingPolicy
      implements FileSystemAccess.FileSystemExecutor<Void> {

    private Path path;

    public FSUnSetErasureCodingPolicy(String path) {
      this.path = new Path(path);

View on GitHub (pinned to 2add963021)

Solutions

  1. Set the HttpFS server's fs.defaultFS to the HDFS nameservice and restart
  2. Query EC policy with WebHDFS directly against the NameNode
  3. Skip EC inspection for deployments known not to be HDFS
  4. Verify which config file the running HttpFS process actually loaded (startup log) before assuming the setting took effect

Example fix

<!-- before: httpfs-site.xml -->
<property><name>fs.defaultFS</name><value>file:///</value></property>
<!-- after -->
<property><name>fs.defaultFS</name><value>hdfs://ns1</value></property>
<!-- restart HttpFS; GETERASURECODINGPOLICY then returns policy JSON -->
Defensive patterns

Strategy: try-catch

Type guard

static DistributedFileSystem asDfs(FileSystem fs) {
  return fs instanceof DistributedFileSystem ? (DistributedFileSystem) fs : null;
}

Try / catch

try {
  ErasureCodingPolicy p = fs.getErasureCodingPolicy(path);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("not supported for HttpFs")) {
    return Optional.empty(); // non-HDFS backing: EC state undefined
  }
  throw e;
}

Prevention

When it happens

Trigger: Client sends op=GETERASURECODINGPOLICY for a path via webhdfs:// when the HttpFS server's fs.defaultFS resolves to a non-HDFS FileSystem.

Common situations: Storage-policy auditing tools walking paths through an HttpFS gateway; mixed lakehouse where some mounts are object storage; stale server config after an HDFS-to-object-store migration.

Related errors


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