apache/hadoop · error · UnsupportedOperationException

{} is not supported

Error message

{} is not supported

What it means

Default branch of the POST-typed WebHDFS switch on the NameNode (post(), which serves APPEND data, CONCAT, TRUNCATE, CREATESNAPSHOT, RENAMESNAPSHOT, UNSETSTORAGEPOLICY, UNSETECPOLICY, ...). The op parsed to a valid Op constant but belongs to PUT, GET, or DELETE, so the handler throws UnsupportedOperationException('<OP> is not supported') and the client receives HTTP 400.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java:1137

    }
    case TRUNCATE:
    {
      validateOpParams(op, newLength);
      // We treat each rest request as a separate client.
      final boolean b = cp.truncate(fullpath, newLength.getValue(),
          "DFSClient_" + DFSUtil.getSecureRandom().nextLong());
      final String js = JsonUtil.toJsonString("boolean", b);
      return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
    }
    case UNSETSTORAGEPOLICY: {
      cp.unsetStoragePolicy(fullpath);
      return Response.ok().build();
    }
    case UNSETECPOLICY:
      cp.unsetErasureCodingPolicy(fullpath);
      return Response.ok().build();
    default:
      throw new UnsupportedOperationException(op + " is not supported");
    }
  }

  /**
   * Handle HTTP GET request for the root.
   *
   * @param ugi User and group information for Hadoop.
   * @param uriInfo An injectable interface that provides access.
   * to application and request URI information.
   * @param delegation Represents delegation token used for authentication.
   * @param username User parameter.
   * @param doAsUser DoAs parameter for proxy user.
   * @param op Http GET operation parameter.
   * @param offset Offset parameter.
   * @param length Length parameter.
   * @param renewer Renewer parameter.
   * @param bufferSize Buffer size parameter.
   * @param xattrNames XAttr Name parameter.

View on GitHub (pinned to 2add963021)

Solutions

  1. Match the verb to the op per the WebHDFS REST table (UNSETSTORAGEPOLICY/UNSECECPOLICY-type ops are POST; SETSTORAGEPOLICY is PUT)
  2. Drive verb selection from a per-op map in the client
  3. Test one representative op per verb against the cluster to validate the client's dispatch table

Example fix

# before: PUT-only op sent as POST
curl -X POST "http://nn:9870/webhdfs/v1/data?op=UNSETSTORAGEPOLICY&user.name=hdfs"
# -> fine (UNSETSTORAGEPOLICY is POST); but:
curl -X POST "http://nn:9870/webhdfs/v1/data?op=SETSTORAGEPOLICY&storagepolicy=WARM"
# 400 ... SETSTORAGEPOLICY is not supported

# after
curl -X PUT "http://nn:9870/webhdfs/v1/data?op=SETSTORAGEPOLICY&storagepolicy=WARM&user.name=hdfs"
Defensive patterns

Strategy: validation

Validate before calling

static final Set<String> POST_OPS = Set.of("APPEND", "CONCAT", "TRUNCATE", "CREATESNAPSHOT",
    "RENAMESNAPSHOT", "UNSETSTORAGEPOLICY", "UNSETECPOLICY", "SETXATTR", "REMOVEXATTR");

static void requirePost(String op) {
  if (!POST_OPS.contains(op.toUpperCase(Locale.ROOT))) {
    throw new IllegalArgumentException(op + " is not a POST operation; check the WebHDFS verb table");
  }
}

Type guard

static boolean isPostOp(String op) {
  return POST_OPS.contains(op.toUpperCase(Locale.ROOT));
}

Try / catch

catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().endsWith("is not supported")) {
    throw new IllegalStateException("verb/verb mismatch sending " + op + " via POST", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: POSTing an operation owned by another verb: curl -X POST '...?op=SETSTORAGEPOLICY' (PUT-only), '...?op=GETFILESTATUS' (GET-only), '...?op=DELETE' (DELETE-only). Also generic clients that always POST because 'POST works for everything'.

Common situations: Wrappers that tunnel every operation through POST; code copied from an example for a different op; ops renamed or re-homed between Hadoop releases; HTML-form-based tools that can only issue GET/POST.

Related errors


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