{"record":{"id":"9fbb7b23630448c7","repo":"apache/hadoop","slug":"invalid-scheme-0-it-should-be-webhdfs-or-sw","errorCode":null,"errorMessage":"Invalid scheme [{0}] it should be 'webhdfs' or 'swebhdfs'","messagePattern":"Invalid scheme \\[(.+?)\\] it should be 'webhdfs' or 'swebhdfs'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSUtils.java","lineNumber":92,"sourceCode":"   * @param path the file path.\n   * @param params the query string parameters.\n   * @param multiValuedParams multi valued parameters of the query string\n   *\n   * @return URL a <code>URL</code> for the HttpFSServer server,\n   *\n   * @throws IOException thrown if an IO error occurs.\n   */\n  static URL createURL(Path path, Map<String, String> params, Map<String, \n      List<String>> multiValuedParams) throws IOException {\n    URI uri = path.toUri();\n    String realScheme;\n    if (uri.getScheme().equalsIgnoreCase(HttpFSFileSystem.SCHEME)) {\n      realScheme = \"http\";\n    } else if (uri.getScheme().equalsIgnoreCase(HttpsFSFileSystem.SCHEME)) {\n      realScheme = \"https\";\n\n    } else {\n      throw new IllegalArgumentException(MessageFormat.format(\n        \"Invalid scheme [{0}] it should be '\" + HttpFSFileSystem.SCHEME + \"' \" +\n            \"or '\" + HttpsFSFileSystem.SCHEME + \"'\", uri));\n    }\n    StringBuilder sb = new StringBuilder();\n    sb.append(realScheme).append(\"://\").append(uri.getAuthority()).\n      append(SERVICE_PATH).append(uri.getPath());\n\n    String separator = \"?\";\n    for (Map.Entry<String, String> entry : params.entrySet()) {\n      sb.append(separator).append(entry.getKey()).append(\"=\").\n        append(URLEncoder.encode(entry.getValue(), \"UTF8\"));\n      separator = \"&\";\n    }\n    if (multiValuedParams != null) {\n      for (Map.Entry<String, List<String>> multiValuedEntry : \n        multiValuedParams.entrySet()) {\n        String name = URLEncoder.encode(multiValuedEntry.getKey(), \"UTF-8\");\n        List<String> values = multiValuedEntry.getValue();","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSUtils.java#L74-L110","documentation":"HttpFSUtils.createURL() maps the FileSystem URI scheme to a transport: webhdfs becomes http, swebhdfs becomes https. Any other scheme throws IllegalArgumentException before a network connection is made. Note the message formats the whole URI into {0} (the code passes `uri`, not `uri.getScheme()`), so the bracketed value you see is the full URI; a URI with no scheme at all NPEs earlier at uri.getScheme().equalsIgnoreCase(...).","triggerScenarios":"FileSystem.get(new URI(\"hdfs://host:14000\", ...), conf) or any operation routed through HttpFSUtils.createURL (getFileStatus, open, listStatus, create...) when the fs URI scheme is hdfs://, file://, httpfs://, or a typo like webhdf://.","commonSituations":"Copying the hdfs:// fs.defaultFS value from core-site.xml into code that instantiates the WebHDFS/HttpFS client; assuming the HttpFS proxy accepts its own 'httpfs' scheme; missing scheme because Path was built from a bare string after config changes.","solutions":["Use webhdfs://host:port for plain HTTP or swebhdfs://host:port for TLS in the FileSystem URI","Check the code path that builds the URI (fs.defaultFS, hard-coded URI, Path) and correct the scheme string","If you see an NPE instead, the URI has no scheme at all: qualify it or set fs.defaultFS so FileSystem.get resolves one","Verify the port is the HttpFS port (default 14000) / NameNode webhdfs port (9870) for the chosen scheme"],"exampleFix":"// before\nFileSystem fs = FileSystem.get(new URI(\"hdfs://httpfs-host:14000\"), conf);\n// after\nFileSystem fs = FileSystem.get(new URI(\"webhdfs://httpfs-host:14000\"), conf);","handlingStrategy":"validation","validationCode":"URI u = new URI(fsUrl);\nString scheme = u.getScheme();\nif (scheme == null || !(scheme.equalsIgnoreCase(\"webhdfs\") || scheme.equalsIgnoreCase(\"swebhdfs\"))) {\n  throw new IllegalArgumentException(\"HttpFS client requires webhdfs:// or swebhdfs://, got: \" + scheme);\n}\nFileSystem fs = FileSystem.get(u, conf);","typeGuard":"static boolean isWebhdfsUri(URI u) {\n  String s = u.getScheme();\n  return \"webhdfs\".equalsIgnoreCase(s) || \"swebhdfs\".equalsIgnoreCase(s);\n}","tryCatchPattern":"try {\n  FileSystem fs = FileSystem.get(new URI(fsUrl), conf);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid scheme\")) {\n    throw new ConfigurationException(\"Set fsUrl to webhdfs://host:14000 or swebhdfs://host:port, was: \" + fsUrl, e);\n  }\n  throw e;\n}","preventionTips":["Validate the scheme at application startup, not per call","Centralize the FileSystem URI in one config key; never copy hdfs:// defaultFS values into it","Remember the printed {0} is the whole URI (format-arg bug), so read the scheme off it manually"],"tags":["webhdfs","httpfs","uri-scheme","misconfiguration","illegalargument"],"backgroundTag":"invalid-uri-scheme","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}