{"record":{"id":"e55e0c341c90ecf8","repo":"apache/hadoop","slug":"invalid-operation-0","errorCode":null,"errorMessage":"Invalid Operation [{0}]","messagePattern":"Invalid Operation \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java","lineNumber":76,"sourceCode":"\n  public Parameters get(HttpServletRequest request) {\n    Map<String, List<Param<?>>> map = new HashMap<>();\n\n    Map<String, String[]> queryString = request.getParameterMap();\n    String str = null;\n    if(queryString.containsKey(driverParam)) {\n      str = queryString.get(driverParam)[0];\n    }\n    if (str == null) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Missing Operation parameter [{0}]\",\n                             driverParam));\n    }\n    Enum op;\n    try {\n      op = Enum.valueOf(enumClass, StringUtils.toUpperCase(str));\n    } catch (IllegalArgumentException ex) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Invalid Operation [{0}]\", str));\n    }\n    if (!paramsDef.containsKey(op)) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Unsupported Operation [{0}]\", op));\n    }\n    for (Class<Param<?>> paramClass : paramsDef.get(op)) {\n      Param<?> param = newParam(paramClass);\n      List<Param<?>> paramList = Lists.newArrayList();\n      String[] ps = queryString.get(param.getName());\n      if (ps != null) {\n        for (String p : ps) {\n          try {\n            param.parseParam(p);\n          }\n          catch (Exception ex) {\n            throw new IllegalArgumentException(ex.toString(), ex);\n          }","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java#L58-L94","documentation":"The op value is resolved with Enum.valueOf on HttpFSFileSystem.Operation after upper-casing (ParametersProvider.java:76); a name that is not an enum constant throws IllegalArgumentException(\"Invalid Operation [str]\") → HTTP 400. Names are case-insensitive on the wire ('getfilestatus' works), but non-existent verbs do not. Valid names are the WebHDFS operations (OPEN, CREATE, APPEND, RENAME, DELETE, LISTSTATUS, GETFILESTATUS, SETREPLICATION, GETXATTR, ...).","triggerScenarios":"Requests like ?op=read, ?op=list, ?op=rm, or typos like ?op=GETFILESTAT. Also version skew: a client using an operation constant added in a newer release (e.g. GETECCODECS) against an older httpfs whose enum lacks it.","commonSituations":"Porting vocabulary from the HDFS CLI or other object-store APIs (rm, ls, read, stat); typo'd operation names in scripts; clients built against a different Hadoop version than the server.","solutions":["Use a valid WebHDFS operation name in op, exactly as documented for the server's version (e.g. op=OPEN, op=GETFILESTATUS).","Resolve version skew: send newer operations only to servers that support them, or upgrade httpfs.","Replace CLI-style verbs with their WebHDFS equivalents (rm → DELETE, ls → LISTSTATUS, read → OPEN).","Catch the 400 client-side and surface the invalid value to the caller/log."],"exampleFix":"# before\ncurl 'http://nn:14000/webhdfs/v1/file?op=read&user.name=hdfs'          # 400 Invalid Operation [read]\n\n# after\ncurl 'http://nn:14000/webhdfs/v1/file?op=OPEN&user.name=hdfs'          # 200","handlingStrategy":"validation","validationCode":"Set<String> OPS = Set.of(\"OPEN\", \"GETFILESTATUS\", \"LISTSTATUS\", \"CREATE\", \"DELETE\", \"RENAME\", \"SETREPLICATION\");\nString op = rawOp == null ? null : rawOp.toUpperCase(Locale.ROOT);\nif (op == null || !OPS.contains(op)) throw new IllegalArgumentException(\"unsupported op: \" + rawOp);","typeGuard":"static boolean isValidOp(String s, Set<String> knownOps) {\n  return s != null && knownOps.contains(s.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"try {\n  Response r = target.queryParam(\"op\", op).request().get(Response.class);\n} // client side: on 400, parse the body for 'Invalid Operation' and surface rawOp\ncatch (ProcessingException ex) { /* connection issues, not validation */ throw ex; }","preventionTips":["Source op names from the Operation enum of the server version you target.","Guard version-specific operations behind a capability check.","Do not invent verbs from other APIs (S3, HDFS CLI) for WebHDFS."],"tags":["java","hadoop","httpfs","rest","webhdfs","enum","query-string"],"backgroundTag":"invalid-enum-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}