{"record":{"id":"ec7980b6d5ca6b3c","repo":"apache/hadoop","slug":"protocol-needs-one-parameter","errorCode":null,"errorMessage":"-protocol needs one parameter","messagePattern":"-protocol needs one parameter","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java","lineNumber":218,"sourceCode":"            \"-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.\n     *\n     * @throws HadoopIllegalArgumentException if arguments are invalid.\n     * @throws Exception if unable to connect\n     */\n    private void doGetLevel() throws Exception {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L200-L236","documentation":"-protocol consumes exactly one following parameter, the scheme name. parseProtocolArgs checks index+1 >= args.length and throws HadoopIllegalArgumentException('-protocol needs one parameter') when -protocol is the last token, i.e., the scheme value is missing. Parsing aborts before the scheme is ever inspected for validity.","triggerScenarios":"'hadoop loglevel -getlevel h c -protocol' with nothing after the flag; shell variable holding the scheme expanding to empty so the flag ends the command; line breaks splitting the flag from its value in a pasted script.","commonSituations":"Truncated copy-paste; unquoted/empty scheme variables in automation; heredocs or line continuations losing the trailing token.","solutions":["Follow -protocol with exactly one value: http or https.","Default the scheme variable in scripts ('${SCHEME:-http}') so the flag never dangles.","Omit -protocol entirely when plain http is acceptable — it is the default."],"exampleFix":"# before\nhadoop loglevel -getlevel nn:9871 cls -protocol\n\n# after\nhadoop loglevel -getlevel nn:9871 cls -protocol https","handlingStrategy":"validation","validationCode":"int i = Arrays.asList(args).indexOf(\"-protocol\");\nif (i >= 0 && i + 1 >= args.length) {\n  throw new HadoopIllegalArgumentException(\"-protocol needs a value: http or https\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always follow -protocol immediately with its value.","Use '${SCHEME:-http}' style defaults in scripts so the flag never dangles.","Drop -protocol entirely when http is fine."],"tags":["hadoop","logging","cli","loglevel","missing-arguments","protocol"],"backgroundTag":"insufficient-cli-arguments","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}