apache/hadoop · error · IllegalArgumentException (InvalidUriException)

{uri}

Error message

{uri}

What it means

Thrown during URI qualification when AzureBlobFileSystem tries to rebuild a URI using the authority of the configured default filesystem URI (which uses an abfs scheme) and java.net.URI rejects the combination with URISyntaxException. The code comments say this should never happen; in practice it means the default URI's authority contains characters illegal in a URI authority component. The result is an IllegalArgumentException wrapping InvalidUriException, whose message is just the offending URI string.

Source

Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java:1607

  private URI ensureAuthority(URI uri, final Configuration conf) {

    Preconditions.checkNotNull(uri, "uri");

    if (uri.getAuthority() == null) {
      final URI defaultUri = FileSystem.getDefaultUri(conf);

      if (defaultUri != null && isAbfsScheme(defaultUri.getScheme())) {
        try {
          // Reconstruct the URI with the authority from the default URI.
          uri = new URI(
              uri.getScheme(),
              defaultUri.getAuthority(),
              uri.getPath(),
              uri.getQuery(),
              uri.getFragment());
        } catch (URISyntaxException e) {
          // This should never happen.
          throw new IllegalArgumentException(new InvalidUriException(uri.toString()));
        }
      }
    }

    if (uri.getAuthority() == null) {
      throw new IllegalArgumentException(new InvalidUriAuthorityException(uri.toString()));
    }

    return uri;
  }

  private boolean isAbfsScheme(final String scheme) {
    if (scheme == null) {
      return false;
    }

    if (scheme.equals(FileSystemUriSchemes.ABFS_SCHEME)
        || scheme.equals(FileSystemUriSchemes.ABFS_SECURE_SCHEME)) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Fix fs.defaultFS to the canonical form abfs://<container>@<account>.dfs.core.windows.net.
  2. URL-encode any special characters in container or account names.
  3. Validate the default URI with new URI(...) at application startup before any FS call.

Example fix

<!-- before -->
<property><name>fs.defaultFS</name><value>abfs://my container@acc ount.dfs.core.windows.net</value></property>

<!-- after -->
<property><name>fs.defaultFS</name><value>abfs://my-container@account.dfs.core.windows.net</value></property>
Defensive patterns

Strategy: validation

Validate before calling

// at startup, before any FS call
URI def = new URI(conf.get("fs.defaultFS"));
URI roundTrip = new URI(def.getScheme(), def.getAuthority(), def.getPath(), null, null);
if (roundTrip.getAuthority() == null) {
  throw new IllegalStateException("fs.defaultFS authority invalid: " + def);
}

Try / catch

try {
  fs.makeQualified(path);
} catch (IllegalArgumentException e) {
  if (e.getCause() instanceof InvalidUriException) {
    throw new ConfigurationException("fs.defaultFS has an illegal authority", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: fs.defaultFS (or the fs URI passed to FileSystem.get) uses an abfs/abfss scheme with an authority containing spaces or other characters illegal in a URI authority, and makeQualified/initialize triggers URI reconstruction.

Common situations: Hand-edited core-site.xml with malformed fs.defaultFS (trailing spaces, unencoded characters, smart quotes from copy-paste); environment variables injecting unencoded account names; templated config rendering bad values.

Related errors


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