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, in

View on GitHub (pinned to 2add963021)

Solutions

  1. Include the scheme: new Path("hdfs://nn:8020/data")
  2. If the target is local, drop the authority instead: new Path("/data") or new Path("file:///data")
  3. 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

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


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/6efe963ed49a8328. Report an issue: GitHub.