{"record":{"id":"039839f66bc49b66","repo":"apache/hadoop","slug":"getlevel-needs-two-parameters","errorCode":null,"errorMessage":"-getlevel needs two parameters","messagePattern":"-getlevel needs two parameters","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java","lineNumber":181,"sourceCode":"            \"Must specify either -getlevel or -setlevel\");\n      }\n\n      // if protocol is unspecified, set it as http.\n      if (protocol == null) {\n        protocol = PROTOCOL_HTTP;\n      }\n    }\n\n    private int parseGetLevelArgs(String[] args, int index) throws\n        HadoopIllegalArgumentException {\n      // fail if multiple operations are specified in the arguments\n      if (operation != Operations.UNKNOWN) {\n        throw new HadoopIllegalArgumentException(\n            \"Redundant -getlevel command\");\n      }\n      // check number of arguments is sufficient\n      if (index+2 >= args.length) {\n        throw new HadoopIllegalArgumentException(\n            \"-getlevel needs two parameters\");\n      }\n      operation = Operations.GETLEVEL;\n      hostName = args[index+1];\n      className = args[index+2];\n      return index+3;\n    }\n\n    private int parseSetLevelArgs(String[] args, int index) throws\n        HadoopIllegalArgumentException {\n      // fail if multiple operations are specified in the arguments\n      if (operation != Operations.UNKNOWN) {\n        throw new HadoopIllegalArgumentException(\n            \"Redundant -setlevel command\");\n      }\n      // check number of arguments is sufficient\n      if (index+3 >= args.length) {\n        throw new HadoopIllegalArgumentException(","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L163-L199","documentation":"-getlevel consumes exactly two following parameters: <host:port> and <classname>. parseGetLevelArgs checks index+2 >= args.length and throws HadoopIllegalArgumentException('-getlevel needs two parameters') when the classname (or both) is missing. Note the check is strict about position: the last usable token must sit at index+2, so a trailing -protocol flag directly after the host does not satisfy it.","triggerScenarios":"'hadoop loglevel -getlevel namenode:9870' (classname forgotten); '-getlevel' as the final token; ordering mistakes like '-getlevel -protocol http ...' where the next tokens are flags, not parameters.","commonSituations":"Truncated commands from copy-paste; scripts forgetting the classname argument; users assuming the class is optional (it is not — it selects the logger).","solutions":["Provide both parameters in order: '-getlevel <host:port> <fully.qualified.ClassName>'.","If you also want -protocol, place it after the two parameters: '-getlevel host:port cls -protocol https'.","Fix the calling script so host and class variables are both non-empty."],"exampleFix":"# before\nhadoop loglevel -getlevel namenode:9870\n\n# after\nhadoop loglevel -getlevel namenode:9870 org.apache.hadoop.ipc.Server","handlingStrategy":"validation","validationCode":"int i = Arrays.asList(args).indexOf(\"-getlevel\");\nif (i >= 0 && (i + 2 >= args.length\n      || args[i+1].startsWith(\"-\") || args[i+2].startsWith(\"-\"))) {\n  throw new HadoopIllegalArgumentException(\n      \"-getlevel needs host:port and classname as the next two tokens\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type the full form '-getlevel <host:port> <fqcn>' every time; the classname is mandatory.","Place -protocol after the two parameters, never between them.","Assert HOST and CLASS are non-empty in scripts before invoking the tool."],"tags":["hadoop","logging","cli","loglevel","missing-arguments"],"backgroundTag":"insufficient-cli-arguments","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}