apache/hadoop · error · InvalidPathException
Path without scheme with non-null authority:{path}
Error message
Path without scheme with non-null authority:{path} What it means
AbstractFileSystem.checkPath rejects a Path whose URI has an authority but no scheme, e.g. the string "//nn:8020/data" which parses to authority "nn:8020" with scheme null. No AbstractFileSystem instance can match such a path, because matching starts from the scheme, so it fails fast with InvalidPathException.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:381
* If the path is fully qualified URI, then its scheme and authority
* matches that of this file system. Otherwise the path must be
* slash-relative name.
* @param path the path.
* @throws InvalidPathException if the path is invalid
*/
public void checkPath(Path path) {
URI uri = path.toUri();
String thatScheme = uri.getScheme();
String thatAuthority = uri.getAuthority();
if (thatScheme == null) {
if (thatAuthority == null) {
if (path.isUriPathAbsolute()) {
return;
}
throw new InvalidPathException("relative paths not allowed:" +
path);
} else {
throw new InvalidPathException(
"Path without scheme with non-null authority:" + path);
}
}
String thisScheme = this.getUri().getScheme();
String thisHost = this.getUri().getHost();
String thatHost = uri.getHost();
// Schemes and hosts must match.
// Allow for null Authority for file:///
if (!thisScheme.equalsIgnoreCase(thatScheme) ||
(thisHost != null &&
!thisHost.equalsIgnoreCase(thatHost)) ||
(thisHost == null && thatHost != null)) {
throw new InvalidPathException("Wrong FS: " + path + ", expected: "
+ this.getUri());
}
// Ports must match, unless this FS instance is using the default port, inView on GitHub (pinned to 2add963021)
Solutions
- Include the scheme: new Path("hdfs://nn:8020/data")
- If the target is local, drop the authority instead: new Path("/data") or new Path("file:///data")
- Audit string manipulation that builds paths and always carry scheme://authority/path together
Example fix
// before
Path p = new Path("//nn1:8020/data/x"); // Path without scheme with non-null authority
// after
Path p = new Path("hdfs://nn1:8020/data/x"); Defensive patterns
Strategy: validation
Validate before calling
URI u = p.toUri();
if (u.getScheme() == null && u.getAuthority() != null) {
throw new IllegalArgumentException("Path needs a scheme (did one get stripped?): " + p);
} Prevention
- Treat paths as opaque URIs; never substring-manipulate them
- When serializing paths, store path.toString() (the full URI) rather than the path part
- Watch for strings starting with "//" — they parse as authority-without-scheme
When it happens
Trigger: new Path("//host/share/file") or new Path("//ns1/data") (leading double slash yields an authority with no scheme); paths deserialized or string-processed in a way that stripped the scheme but kept "//host:port/"; concatenating an authority into a path string without the scheme prefix.
Common situations: Splitting/joining URI strings and losing the "hdfs:" prefix; copying authority-bearing path strings between configs; hand-built path strings that start with "//" to denote servers (SMB-style habits).
Related errors
- Wrong scheme: %s, in path: %s, expected scheme: %s
- GCS path supports only '%s' scheme, instead got '%s' from '%
- Unsupported name: has scheme but relative path-part
- Path is relative
- Wrong bucket: %s, in path: %s, expected bucket: %s
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6efe963ed49a8328.
Report an issue: GitHub.