{"record":{"id":"63fd013cf34258f0","repo":"apache/hadoop","slug":"unsupported-operation-0","errorCode":null,"errorMessage":"Unsupported Operation [{0}]","messagePattern":"Unsupported 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":80,"sourceCode":"    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          }\n          paramList.add(param);\n          param = newParam(paramClass);\n        }\n      } else {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java#L62-L98","documentation":"After op resolves to a valid enum constant, ParametersProvider.get checks the provider's paramsDef map (ParametersProvider.java:80); if the operation has no registered parameter classes it throws IllegalArgumentException(\"Unsupported Operation [...]\") → HTTP 400. The stock HttpFSParametersProvider registers every Operation constant, so in a vanilla server this never fires — it is the signature of a fork or embedded wsrs framework that added an enum constant without a PARAMS_DEF entry.","triggerScenarios":"Adding Operation.MYOP (or a constant in a custom driver enum passed to your own ParametersProvider) without paramsDef.put(MYOP, new Class[]{...}); the first ?op=MYOP request parses the enum fine but fails the map lookup and throws.","commonSituations":"Vendored httpfs with custom operations; a PARAMS_DEF entry deleted while the enum constant stayed; copy-paste mistakes when wiring a new provider's static initializer.","solutions":["Register every operation in the provider's static init: PARAMS_DEF.put(Operation.YOUROP, new Class[]{ YourParam.class, ... }).","If the operation must not be served, remove the enum constant so clients get the clearer 'Invalid Operation' message, or block it at the auth/filter layer.","Add a unit test asserting paramsDef.keySet() equals all enum constants.","Treat any occurrence as a server wiring bug and fix the provider, not the client."],"exampleFix":"// before\npublic static final Map<Operation, Class<Param<?>>[]> PARAMS_DEF = new HashMap<>();\nstatic { PARAMS_DEF.put(Operation.GETFILESTATUS, new Class[]{}); }\n// Operation.MYOP exists in the enum but is never registered -> 400 Unsupported Operation\n\n// after\nstatic { \n  PARAMS_DEF.put(Operation.GETFILESTATUS, new Class[]{});\n  PARAMS_DEF.put(Operation.MYOP, new Class[]{ MyOpParam.class });\n}","handlingStrategy":"validation","validationCode":"EnumSet<Op> registered = EnumSet.noneOf(Op.class);\nregistered.addAll(paramsDef.keySet());\nif (!registered.equals(EnumSet.allOf(Op.class))) {\n  throw new IllegalStateException(\"paramsDef missing entries for: \" + EnumSet.complementOf(registered));\n}","typeGuard":"static boolean isRegistered(Enum<?> op, Map<Enum, ?> paramsDef) {\n  return paramsDef.containsKey(op);\n}","tryCatchPattern":"try {\n  params = provider.get(request);\n} catch (IllegalArgumentException ex) {\n  if (ex.getMessage().contains(\"Unsupported Operation\")) {\n    LOG.error(\"provider wiring bug: operation not in paramsDef\", ex);\n    return serverError();\n  }\n  throw ex;\n}","preventionTips":["Every new Operation constant must ship with its PARAMS_DEF.put in the same commit.","Unit test: paramsDef.keySet() == EnumSet.allOf(Operation.class).","Treat 'Unsupported Operation' on a stock server as a fork bug, not a client error."],"tags":["java","hadoop","httpfs","jax-rs","provider-registration"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}