apache/hadoop · error · HadoopIllegalArgumentException
Uri without authority: {uri}
Error message
Uri without authority: {uri} What it means
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.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:329
*
* @return URI of the file system
*
* @throws URISyntaxException <code>uri</code> has syntax error
*/
private URI getUri(URI uri, String supportedScheme,
boolean authorityNeeded, int defaultPort) throws URISyntaxException {
checkScheme(uri, supportedScheme);
// A file system implementation that requires authority must always
// specify default port
if (defaultPort < 0 && authorityNeeded) {
throw new HadoopIllegalArgumentException(
"FileSystem implementation error - default port " + defaultPort
+ " is not valid");
}
String authority = uri.getAuthority();
if (authority == null) {
if (authorityNeeded) {
throw new HadoopIllegalArgumentException("Uri without authority: " + uri);
} else {
return new URI(supportedScheme + ":///");
}
}
// authority is non null - AuthorityNeeded may be true or false.
int port = uri.getPort();
port = (port == -1 ? defaultPort : port);
if (port == -1) { // no port supplied and default port is not specified
return new URI(supportedScheme, authority, "/", null);
}
return new URI(supportedScheme + "://" + uri.getHost() + ":" + port);
}
/**
* The default port of this file system.
*
* @return default port of this file system's Uri scheme
* A uri with a port of -1 => default port;View on GitHub (pinned to 2add963021)
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
Example fix
// before
AbstractFileSystem afs = AbstractFileSystem.get(new URI("hdfs:///"), conf); // Uri without authority: hdfs:///
// after
AbstractFileSystem afs = AbstractFileSystem.get(new URI("hdfs://ns1/"), conf); // HA logical authority Defensive patterns
Strategy: validation
Validate before calling
URI u = path.toUri();
if (u.getScheme() != null && u.getAuthority() == null && schemeRequiresAuthority(conf, u.getScheme())) {
// rebuild with the configured default authority before touching the FS
URI def = FileSystem.getDefaultUri(conf);
u = new URI(u.getScheme(), def.getAuthority(), u.getPath(), null, null);
path = new Path(u);
} Try / catch
try { AbstractFileSystem.get(uri, conf); } catch (HadoopIllegalArgumentException e) { if (e.getMessage().startsWith("Uri without authority")) { /* fix uri/config, retry once */ } else throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Wrong FS: {path}, expected: {this.getUri()}
- Bad configuration of hadoop.security.key.provider.path at ${
- Wrong FS: {path} and port={thatPort}, expected: {this.getUri
- No scheme in default FS: ${uri}
- Could not initialize target File System for URI : {targetDir
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/8642610887f7b34d.
Report an issue: GitHub.