{"record":{"id":"6428aef384bbb119","repo":"apache/hadoop","slug":"redundant-getlevel-command","errorCode":null,"errorMessage":"Redundant -getlevel command","messagePattern":"Redundant -getlevel command","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java","lineNumber":176,"sourceCode":"      }\n\n      // if operation is never specified in the arguments\n      if (operation == Operations.UNKNOWN) {\n        throw new HadoopIllegalArgumentException(\n            \"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(","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L158-L194","documentation":"parseGetLevelArgs throws HadoopIllegalArgumentException('Redundant -getlevel command') when a second -getlevel flag is encountered, because the operation enum is already set to GETLEVEL. The log-level tool accepts exactly one operation per invocation; combining or repeating operations is rejected at parse time.","triggerScenarios":"'hadoop loglevel -getlevel h:9870 cls -getlevel h:9870 cls2'; a duplicated flag from a shell loop or a for-loop bug appending the flag twice; copy-paste concatenation of two commands.","commonSituations":"Bash history editing duplicating a flag; wrapper scripts appending '-getlevel ...' to a variable that already contained it; documentation examples pasted back to back.","solutions":["Remove the duplicate — issue exactly one -getlevel (or one -setlevel) per invocation.","Run separate invocations for separate queries instead of chaining flags.","Fix the script that builds the command so it appends the operation exactly once."],"exampleFix":"# before\nhadoop loglevel -getlevel nn:9870 A -getlevel nn:9870 B\n\n# after\nhadoop loglevel -getlevel nn:9870 A && hadoop loglevel -getlevel nn:9870 B","handlingStrategy":"validation","validationCode":"long n = Arrays.stream(args).filter(a -> a.equals(\"-getlevel\")).count();\nif (n > 1) {\n  throw new HadoopIllegalArgumentException(\"-getlevel may appear only once\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Issue one operation per invocation; chain with && for multiple queries.","Never concatenate two full loglevel commands into one line.","Check command templates for loops that can append the flag twice."],"tags":["hadoop","logging","cli","loglevel","duplicate-flag"],"backgroundTag":"duplicate-cli-flag","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}