apache/hadoop · error · IOException

Invalid HTTP POST operation [{0}]

Error message

Invalid HTTP POST operation [{0}]

What it means

HttpFSServer.post() handles the POST-verb operations (APPEND, CONCAT, (TRUNCATE), SETREPLICATION? no — POST set: APPEND, CONCAT, TRUNCATE, MODIFYACLRULES..., SETSTORAGEPOLICY, UNSETECPOLICY, etc.) and throws IOException('Invalid HTTP POST operation [<op>]') from the default branch for any op not registered for POST on this server.

Source

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

      }
      case UNSETSTORAGEPOLICY: {
        FSOperations.FSUnsetStoragePolicy command =
             new FSOperations.FSUnsetStoragePolicy(path);
         fsExecute(user, command);
         AUDIT_LOG.info("Unset storage policy [{}]", path);
         response = Response.ok().build();
         break;
      }
      case UNSETECPOLICY: {
        FSOperations.FSUnSetErasureCodingPolicy command =
            new FSOperations.FSUnSetErasureCodingPolicy(path);
        fsExecute(user, command);
        AUDIT_LOG.info("Unset ec policy [{}]", path);
        response = Response.ok().build();
        break;
      }
      default: {
        throw new IOException(
          MessageFormat.format("Invalid HTTP POST operation [{0}]",
                               op.value()));
      }
    }
    return response;
  }

  /**
   * Creates the URL for an upload operation (create or append).
   *
   * @param uriInfo uri info of the request.
   * @param uploadOperation operation for the upload URL.
   *
   * @return the URI for uploading data.
   */
  protected URI createUploadRedirectionURL(UriInfo uriInfo, Enum<?> uploadOperation) {
    UriBuilder uriBuilder = uriInfo.getRequestUriBuilder();
    uriBuilder = uriBuilder.replaceQueryParam(OperationParam.NAME, uploadOperation)

View on GitHub (pinned to 2add963021)

Solutions

  1. Confirm the op is a POST op in the WebHDFS spec (APPEND, CONCAT, TRUNCATE, SETSTORAGEPOLICY, UNSETECPOLICY, ...) and spelled exactly.
  2. If the op is unknown to this server version, upgrade HttpFS or pick an equivalent supported op.
  3. For file creation remember the CREATE flow is PUT + redirect, not POST.

Example fix

# before
$ curl -X POST 'http://host:14000/webhdfs/v1/tmp/a?op=CONCATENATE&user.name=alice'

# after
$ curl -X POST 'http://host:14000/webhdfs/v1/tmp/a?op=CONCAT&sources=/tmp/b&user.name=alice'
Defensive patterns

Strategy: validation

Validate before calling

Set<String> POST_OPS = Set.of("APPEND","CONCAT","TRUNCATE","SETSTORAGEPOLICY",
    "SETREPLICATION"/*per server version*/,"UNSETECPOLICY"/*per server version*/);
if (!POST_OPS.contains(op)) {
  throw new IllegalArgumentException(op + " is not a POST operation on this server");
}

Type guard

static boolean isValidPostOp(String op) {
  return Set.of("APPEND", "CONCAT", "TRUNCATE", "SETSTORAGEPOLICY", "UNSETECPOLICY").contains(op);
}

Try / catch

try {
  resp = http.post(buildUrl(op), payload);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("Invalid HTTP POST operation")) {
    throw new IllegalArgumentException("Wrong verb or unsupported op " + op, e);
  }
  throw e;
}

Prevention

When it happens

Trigger: POST ?op=COPY (not an HttpFS op at all); POST ?op=UNSETECPOLICY against an older HttpFS that lacks EC support (pre-Hadoop-3.x); POST ?op=CREATE (CREATE is a two-step PUT op); misspelled ops such as op=CONCATENATE.

Common situations: Clients written for newer Hadoop hitting older HttpFS during rolling upgrades; generic REST tooling defaulting to POST; EC/snapshot-era ops sent to legacy servers; op names guessed from Java API names rather than the REST spec.

Related errors


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