{"record":{"id":"94d080111f5c6859","repo":"apache/hadoop","slug":"redundant-protocol-command","errorCode":null,"errorMessage":"Redundant -protocol command","messagePattern":"Redundant -protocol 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":213,"sourceCode":"            \"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) {\n        throw new HadoopIllegalArgumentException(\n            \"Redundant -protocol command\");\n      }\n      // check number of arguments is sufficient\n      if (index+1 >= args.length) {\n        throw new HadoopIllegalArgumentException(\n            \"-protocol needs one parameter\");\n      }\n      // check protocol is valid\n      protocol = args[index+1];\n      if (!isValidProtocol(protocol)) {\n        throw new HadoopIllegalArgumentException(\n            \"Invalid protocol: \" + protocol);\n      }\n      return index+2;\n    }\n\n    /**\n     * Send HTTP/HTTPS request to get log level.","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L195-L231","documentation":"parseProtocolArgs throws HadoopIllegalArgumentException('Redundant -protocol command') when -protocol is supplied more than once, because the protocol field is already non-null. The tool accepts -protocol at most once per invocation (defaulting to http when omitted).","triggerScenarios":"'hadoop loglevel -getlevel h c -protocol http -protocol https'; commands assembled by combining fragments that each carry their own -protocol; copy-paste duplication.","commonSituations":"Merging two example commands into one line; wrappers that add -protocol https on top of a user-supplied command that already has it.","solutions":["Keep a single -protocol (http|https) token — or drop it entirely to use the http default.","Fix wrapper scripts so they do not stack a -protocol onto an already-complete command.","If both variants are needed, run two separate invocations."],"exampleFix":"# before\nhadoop loglevel -getlevel nn:9871 cls -protocol https -protocol http\n\n# after\nhadoop loglevel -getlevel nn:9871 cls -protocol https","handlingStrategy":"validation","validationCode":"long n = Arrays.stream(args).filter(a -> a.equals(\"-protocol\")).count();\nif (n > 1) {\n  throw new HadoopIllegalArgumentException(\"-protocol may appear only once (default http)\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use -protocol at most once; omit it for the http default.","Do not merge two example commands that each carry -protocol.","Review wrapper scripts that append -protocol https automatically."],"tags":["hadoop","logging","cli","loglevel","duplicate-flag","protocol"],"backgroundTag":"duplicate-cli-flag","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}