{"record":{"id":"28e5bdbf00faac21","repo":"apache/hadoop","slug":"invalid-http-post-operation-0","errorCode":null,"errorMessage":"Invalid HTTP POST operation [{0}]","messagePattern":"Invalid HTTP POST operation \\[(.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":500,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java","lineNumber":790,"sourceCode":"      }\n      case UNSETSTORAGEPOLICY: {\n        FSOperations.FSUnsetStoragePolicy command =\n             new FSOperations.FSUnsetStoragePolicy(path);\n         fsExecute(user, command);\n         AUDIT_LOG.info(\"Unset storage policy [{}]\", path);\n         response = Response.ok().build();\n         break;\n      }\n      case UNSETECPOLICY: {\n        FSOperations.FSUnSetErasureCodingPolicy command =\n            new FSOperations.FSUnSetErasureCodingPolicy(path);\n        fsExecute(user, command);\n        AUDIT_LOG.info(\"Unset ec policy [{}]\", path);\n        response = Response.ok().build();\n        break;\n      }\n      default: {\n        throw new IOException(\n          MessageFormat.format(\"Invalid HTTP POST operation [{0}]\",\n                               op.value()));\n      }\n    }\n    return response;\n  }\n\n  /**\n   * Creates the URL for an upload operation (create or append).\n   *\n   * @param uriInfo uri info of the request.\n   * @param uploadOperation operation for the upload URL.\n   *\n   * @return the URI for uploading data.\n   */\n  protected URI createUploadRedirectionURL(UriInfo uriInfo, Enum<?> uploadOperation) {\n    UriBuilder uriBuilder = uriInfo.getRequestUriBuilder();\n    uriBuilder = uriBuilder.replaceQueryParam(OperationParam.NAME, uploadOperation)","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java#L772-L808","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the op is a POST op in the WebHDFS spec (APPEND, CONCAT, TRUNCATE, SETSTORAGEPOLICY, UNSETECPOLICY, ...) and spelled exactly.","If the op is unknown to this server version, upgrade HttpFS or pick an equivalent supported op.","For file creation remember the CREATE flow is PUT + redirect, not POST."],"exampleFix":"# before\n$ curl -X POST 'http://host:14000/webhdfs/v1/tmp/a?op=CONCATENATE&user.name=alice'\n\n# after\n$ curl -X POST 'http://host:14000/webhdfs/v1/tmp/a?op=CONCAT&sources=/tmp/b&user.name=alice'","handlingStrategy":"validation","validationCode":"Set<String> POST_OPS = Set.of(\"APPEND\",\"CONCAT\",\"TRUNCATE\",\"SETSTORAGEPOLICY\",\n    \"SETREPLICATION\"/*per server version*/,\"UNSETECPOLICY\"/*per server version*/);\nif (!POST_OPS.contains(op)) {\n  throw new IllegalArgumentException(op + \" is not a POST operation on this server\");\n}","typeGuard":"static boolean isValidPostOp(String op) {\n  return Set.of(\"APPEND\", \"CONCAT\", \"TRUNCATE\", \"SETSTORAGEPOLICY\", \"UNSETECPOLICY\").contains(op);\n}","tryCatchPattern":"try {\n  resp = http.post(buildUrl(op), payload);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid HTTP POST operation\")) {\n    throw new IllegalArgumentException(\"Wrong verb or unsupported op \" + op, e);\n  }\n  throw e;\n}","preventionTips":["Remember CREATE is PUT + redirect, APPEND is POST; build helpers per op.","Check feature availability (EC, storage policy) on the server version before using its ops.","Keep client/server versions aligned during rolling upgrades."],"tags":["httpfs","webhdfs","rest-api","http-post","operation-dispatch","bad-request"],"backgroundTag":"invalid-operation-param","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}