{"record":{"id":"8642610887f7b34d","repo":"apache/hadoop","slug":"uri-without-authority-uri","errorCode":null,"errorMessage":"Uri without authority: {uri}","messagePattern":"Uri without authority: (.+?)","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":329,"sourceCode":"   * \n   * @return URI of the file system\n   * \n   * @throws URISyntaxException <code>uri</code> has syntax error\n   */\n  private URI getUri(URI uri, String supportedScheme,\n      boolean authorityNeeded, int defaultPort) throws URISyntaxException {\n    checkScheme(uri, supportedScheme);\n    // A file system implementation that requires authority must always\n    // specify default port\n    if (defaultPort < 0 && authorityNeeded) {\n      throw new HadoopIllegalArgumentException(\n          \"FileSystem implementation error -  default port \" + defaultPort\n              + \" is not valid\");\n    }\n    String authority = uri.getAuthority();\n    if (authority == null) {\n       if (authorityNeeded) {\n         throw new HadoopIllegalArgumentException(\"Uri without authority: \" + uri);\n       } else {\n         return new URI(supportedScheme + \":///\");\n       }   \n    }\n    // authority is non null  - AuthorityNeeded may be true or false.\n    int port = uri.getPort();\n    port = (port == -1 ? defaultPort : port);\n    if (port == -1) { // no port supplied and default port is not specified\n      return new URI(supportedScheme, authority, \"/\", null);\n    }\n    return new URI(supportedScheme + \"://\" + uri.getHost() + \":\" + port);\n  }\n  \n  /**\n   * The default port of this file system.\n   * \n   * @return default port of this file system's Uri scheme\n   *         A uri with a port of -1 =&gt; default port;","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L311-L347","documentation":"Thrown from the URI-formatting logic of the AbstractFileSystem constructor: a file system registered with authorityNeeded=true (e.g. hdfs, which must know which NameNode to talk to) was constructed from a URI whose authority component is null, such as hdfs:///. At this layer Hadoop cannot guess a NameNode for you, so instance creation fails immediately with HadoopIllegalArgumentException.","triggerScenarios":"AbstractFileSystem.get(new URI(\"hdfs:///\"), conf), FileContext.getFileContext(...) resolving a Path like new Path(\"hdfs:///data/x\") through FileContext#getFSofPath, or a custom AbstractFileSystem subclass calling super(uri, scheme, true, port) with an authority-less URI.","commonSituations":"fs.defaultFS (or a viewfs mount-table entry) configured as \"hdfs:///\" with the namenode host:port omitted; URIs built by string concatenation that drop the authority; code ported from file:/// (which needs no authority) to hdfs; HA setups where the logical nameservice id was left out of the URI.","solutions":["Add the authority to the URI: hdfs://namenode:8020/path, or for HA the logical name hdfs://myNameservice/path","Fix the configuration source of the URI (fs.defaultFS, mount table entries, job.xml) so it includes host:port or nameservice","For custom file systems: pass authorityNeeded=false to the AbstractFileSystem constructor if the scheme genuinely has no authority","Qualify relative/authority-less paths against a correctly configured default FS (Path.makeQualified / FileContext.fixRelativePart) before resolving them"],"exampleFix":"// before\nAbstractFileSystem afs = AbstractFileSystem.get(new URI(\"hdfs:///\"), conf); // Uri without authority: hdfs:///\n\n// after\nAbstractFileSystem afs = AbstractFileSystem.get(new URI(\"hdfs://ns1/\"), conf); // HA logical authority","handlingStrategy":"validation","validationCode":"URI u = path.toUri();\nif (u.getScheme() != null && u.getAuthority() == null && schemeRequiresAuthority(conf, u.getScheme())) {\n  // rebuild with the configured default authority before touching the FS\n  URI def = FileSystem.getDefaultUri(conf);\n  u = new URI(u.getScheme(), def.getAuthority(), u.getPath(), null, null);\n  path = new Path(u);\n}","typeGuard":null,"tryCatchPattern":"try { AbstractFileSystem.get(uri, conf); } catch (HadoopIllegalArgumentException e) { if (e.getMessage().startsWith(\"Uri without authority\")) { /* fix uri/config, retry once */ } else throw e; }","preventionTips":["Always write scheme URIs in full form scheme://authority/path in configs and code","Validate fs.defaultFS and viewfs mount entries contain an authority for authority-requiring schemes","Never build URIs by naive string concatenation of scheme + path"],"tags":["hadoop","uri","authority","filesystem","configuration"],"backgroundTag":"uri-missing-authority","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}