{"record":{"id":"78a98b3a43fe769d","repo":"apache/hadoop","slug":"redundant-setlevel-command","errorCode":null,"errorMessage":"Redundant -setlevel command","messagePattern":"Redundant -setlevel 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":194,"sourceCode":"        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(\n            \"-setlevel needs three parameters\");\n      }\n      operation = Operations.SETLEVEL;\n      hostName = args[index+1];\n      className = args[index+2];\n      level = args[index+3];\n      return index+4;\n    }\n\n    private int parseProtocolArgs(String[] args, int index) throws\n        HadoopIllegalArgumentException {\n      // make sure only -protocol is specified\n      if (protocol != null) {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L176-L212","documentation":"parseSetLevelArgs throws HadoopIllegalArgumentException('Redundant -setlevel command') when -setlevel appears a second time, because the operation enum is already SETLEVEL. The tool accepts exactly one operation per run, so repeated or mixed operation flags fail fast during parsing, before any HTTP request is made.","triggerScenarios":"'hadoop loglevel -setlevel h:9870 cls DEBUG -setlevel ...'; command built by concatenating fragments that each already contain the flag; mixed '-getlevel ... -setlevel ...' also lands here (the second operation flag trips the redundancy check).","commonSituations":"Script loops or conditionals appending the operation flag twice; copy-paste of two full commands into one line; shell aliases that pre-append -setlevel.","solutions":["Keep exactly one operation flag per invocation.","Execute multiple level changes as separate commands.","Audit aliases/wrappers that may already inject -setlevel before your extra flag is appended."],"exampleFix":"# before\nhadoop loglevel -setlevel nn:9870 A DEBUG -setlevel nn:9870 B INFO\n\n# after\nhadoop loglevel -setlevel nn:9870 A DEBUG && hadoop loglevel -setlevel nn:9870 B INFO","handlingStrategy":"validation","validationCode":"long n = Arrays.stream(args).filter(a -> a.equals(\"-setlevel\")).count();\nif (n > 1) {\n  throw new HadoopIllegalArgumentException(\"-setlevel may appear only once\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One operation flag per command; run separate commands for multiple classes.","Watch for aliases/wrappers that already inject -setlevel.","Mixed -getlevel plus -setlevel in one line is always rejected."],"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"}