{"record":{"id":"2ce56fa3c22d5e46","repo":"apache/hadoop","slug":"passed-uri-s-scheme-is-not-for-hdfs","errorCode":null,"errorMessage":"Passed URI's scheme is not for Hdfs","messagePattern":"Passed URI's scheme is not for Hdfs","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/fs/Hdfs.java","lineNumber":84,"sourceCode":"\n  static {\n    HdfsConfiguration.init();\n  }\n\n  /**\n   * This constructor has the signature needed by\n   * {@link AbstractFileSystem#createFileSystem(URI, Configuration)}\n   * \n   * @param theUri which must be that of Hdfs\n   * @param conf configuration\n   * @throws IOException\n   */\n  Hdfs(final URI theUri, final Configuration conf) throws IOException, URISyntaxException {\n    super(theUri, HdfsConstants.HDFS_URI_SCHEME, true,\n        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);\n\n    if (!theUri.getScheme().equalsIgnoreCase(HdfsConstants.HDFS_URI_SCHEME)) {\n      throw new IllegalArgumentException(\"Passed URI's scheme is not for Hdfs\");\n    }\n    String host = theUri.getHost();\n    if (host == null) {\n      throw new IOException(\"Incomplete HDFS URI, no host: \" + theUri);\n    }\n\n    this.dfs = new DFSClient(theUri, conf, getStatistics());\n  }\n\n  @Override\n  public int getUriDefaultPort() {\n    return HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT;\n  }\n\n  @Override\n  public HdfsDataOutputStream createInternal(Path f,\n      EnumSet<CreateFlag> createFlag, FsPermission absolutePermission,\n      int bufferSize, short replication, long blockSize, Progressable progress,","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/fs/Hdfs.java#L66-L102","documentation":"Hdfs is the AbstractFileSystem implementation (used via FileContext) for the hdfs:// scheme. Its constructor — invoked by AbstractFileSystem.createFileSystem from the fs.AbstractFileSystem.<scheme>.impl config mapping — asserts theUri.getScheme() equals \"hdfs\" (case-insensitively) and throws IllegalArgumentException otherwise, guarding against a scheme-to-implementation mapping mismatch.","triggerScenarios":"A URI whose scheme is not hdfs is dispatched to this class: fs.AbstractFileSystem.<scheme>.impl mistakenly set to org.apache.hadoop.fs.Hdfs for another scheme (e.g. webhdfs or a custom one), or code constructing Hdfs directly with a file:// or other URI.","commonSituations":"Copy-paste errors in core-site.xml fs.AbstractFileSystem.*.impl entries; custom FileContext tooling that hardcodes the Hdfs class for any URI; confusing the FileContext impl namespace (fs.AbstractFileSystem.*) with the FileSystem one (fs.*.impl).","solutions":["Use hdfs:// URIs with this implementation","Audit core-site.xml: fs.AbstractFileSystem.hdfs.impl should map to org.apache.hadoop.fs.Hdfs, and every other scheme to its own impl class","For webhdfs://, use the WebHdfs AbstractFileSystem impl instead of routing the scheme at Hdfs"],"exampleFix":"<!-- before (core-site.xml) -->\n<property>\n  <name>fs.AbstractFileSystem.myproto.impl</name>\n  <value>org.apache.hadoop.fs.Hdfs</value>\n</property>\n\n<!-- after -->\n<property>\n  <name>fs.AbstractFileSystem.hdfs.impl</name>\n  <value>org.apache.hadoop.fs.Hdfs</value>\n</property>","handlingStrategy":"validation","validationCode":"URI u = new URI(\"hdfs\", \"nn1\", \"/path\", null);\nif (!\"hdfs\".equalsIgnoreCase(u.getScheme())) {\n  throw new IllegalArgumentException(\"need an hdfs:// URI, got: \" + u);\n}\nFileContext fc = FileContext.getFileContext(u, conf);","typeGuard":"static boolean isHdfsUri(URI u) {\n  return u != null && \"hdfs\".equalsIgnoreCase(u.getScheme());\n}","tryCatchPattern":"try {\n  AbstractFileSystem.createFileSystem(u, conf);\n} catch (IllegalArgumentException e) {\n  // scheme/impl mapping mismatch in fs.AbstractFileSystem.*.impl\n}","preventionTips":["Audit every fs.AbstractFileSystem.<scheme>.impl entry in core-site.xml","Route only hdfs:// URIs at org.apache.hadoop.fs.Hdfs","Use the dedicated impl class for webhdfs and other schemes"],"tags":["hdfs","uri","configuration","filecontext","hadoop"],"backgroundTag":"uri-scheme-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}