{"record":{"id":"009e0d1f7ba34ae8","repo":"apache/hadoop","slug":"invalid-protocol-protocol","errorCode":null,"errorMessage":"\"Invalid protocol: \" + protocol","messagePattern":"\"Invalid protocol: \" \\+ protocol","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java","lineNumber":224,"sourceCode":"      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 {\n      process(protocol + \"://\" + hostName + \"/logLevel?log=\" + className);\n    }\n\n    /**\n     * Send HTTP/HTTPS request to set log level.\n     *","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L206-L242","documentation":"After -protocol consumes its single parameter, LogLevel.isValidProtocol accepts only the exact lowercase strings 'http' and 'https' (PROTOCOL_HTTP/PROTOCOL_HTTPS, compared with equals). Anything else — 'HTTP', 'Http', 'hdfs', 'hadooprpc' — throws HadoopIllegalArgumentException('Invalid protocol: ...'). The scheme also decides which client path runs: doGetLevel/doSetLevel use AuthenticatedURL and SSLFactory accordingly.","triggerScenarios":"'-protocol HTTP' or '-protocol Https' (case mismatch); '-protocol hdfs' or other scheme names; values with trailing whitespace or quotes from shell expansion.","commonSituations":"Uppercase scheme habits from URLs/browsers; scripts passing a generic $SCHEME variable used for other tools; quoting artifacts from wrappers.","solutions":["Use exactly 'http' or 'https' in lowercase.","Normalize in scripts: SCHEME=$(echo \"$SCHEME\" | tr 'A-Z' 'a-z') and strip whitespace.","If the daemon's admin UI is SSL-enabled, remember it must be https with the proper SSLFactory setup on the daemon side."],"exampleFix":"# before\nhadoop loglevel -getlevel nn:9871 cls -protocol HTTPS\n\n# after\nhadoop loglevel -getlevel nn:9871 cls -protocol https","handlingStrategy":"validation","validationCode":"if (!LogLevel.isValidProtocol(scheme)) {\n  throw new HadoopIllegalArgumentException(\n      \"protocol must be exactly 'http' or 'https' (lowercase), got: \" + scheme);\n}\n// or reuse the public helper directly: LogLevel.isValidProtocol(args[i+1])","typeGuard":"boolean isSupportedLogLevelProtocol(String s) {\n  return s != null && (\"http\".equals(s) || \"https\".equals(s));\n}","tryCatchPattern":null,"preventionTips":["Type the scheme in lowercase exactly: http or https.","Normalize scheme variables in scripts: tr 'A-Z' 'a-z' and trim whitespace.","Use https only when the daemon's admin UI is SSL-enabled; otherwise the request fails later with a connection error."],"tags":["hadoop","logging","cli","loglevel","protocol","invalid-value"],"backgroundTag":"invalid-cli-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}