apache/hadoop · error · IllegalArgumentException

Unsupported scheme: {}

Error message

Unsupported scheme: {}

What it means

DFSUtilClient.getHaNnWebHdfsAddresses(conf, scheme) resolves the HA NameNode HTTP addresses for the two WebHDFS schemes: 'webhdfs' maps to dfs.namenode.http-address entries and 'swebhdfs' to dfs.namenode.https-address entries. Any other scheme — including null, 'hdfs', or differently-cased variants — is rejected with IllegalArgumentException('Unsupported scheme: ...') because the helper is WebHDFS-specific.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java:271

      HdfsClientConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY);
  }

  /**
   * Returns list of InetSocketAddress corresponding to HA NN HTTP addresses from
   * the configuration.
   *
   * @return list of InetSocketAddresses
   */
  public static Map<String, Map<String, InetSocketAddress>> getHaNnWebHdfsAddresses(
      Configuration conf, String scheme) {
    if (WebHdfsConstants.WEBHDFS_SCHEME.equals(scheme)) {
      return getAddresses(conf, null,
          HdfsClientConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY);
    } else if (WebHdfsConstants.SWEBHDFS_SCHEME.equals(scheme)) {
      return getAddresses(conf, null,
          HdfsClientConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY);
    } else {
      throw new IllegalArgumentException("Unsupported scheme: " + scheme);
    }
  }

  /**
   * Convert a LocatedBlocks to BlockLocations[]
   * @param blocks a LocatedBlocks
   * @return an array of BlockLocations
   */
  public static BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks) {
    if (blocks == null) {
      return new BlockLocation[0];
    }
    return locatedBlocks2Locations(blocks.getLocatedBlocks());
  }

  /**
   * Convert a List to BlockLocation[]
   * @param blocks A List to be converted

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass the constants: WebHdfsConstants.WEBHDFS_SCHEME or WebHdfsConstants.SWEBHDFS_SCHEME.
  2. Normalize input before the call: trim and lowercase the scheme string, reject null early.
  3. For plain HDFS RPC addresses use the NameNode RPC address helpers (DFSUtil/NameNodeServiceAddresses) instead of the WebHDFS one.
  4. Catch IllegalArgumentException in front-end code to reject malformed requests with a clear message.

Example fix

// before
Map<String, Map<String, InetSocketAddress>> addrs =
    DFSUtilClient.getHaNnWebHdfsAddresses(conf, uri.getScheme()); // 'hdfs' -> throws

// after
String scheme = uri.getScheme() == null ? null : uri.getScheme().toLowerCase(Locale.ROOT);
if (!WebHdfsConstants.WEBHDFS_SCHEME.equals(scheme)
    && !WebHdfsConstants.SWEBHDFS_SCHEME.equals(scheme)) {
  throw new IllegalArgumentException("Scheme must be webhdfs or swebhdfs: " + scheme);
}
Map<String, Map<String, InetSocketAddress>> addrs =
    DFSUtilClient.getHaNnWebHdfsAddresses(conf, scheme);
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<String> WEBHDFS_SCHEMES =
    Set.of(WebHdfsConstants.WEBHDFS_SCHEME, WebHdfsConstants.SWEBHDFS_SCHEME);

String scheme = uri.getScheme();
if (scheme != null) {
  scheme = scheme.toLowerCase(Locale.ROOT);
}
if (!WEBHDFS_SCHEMES.contains(scheme)) {
  throw new IllegalArgumentException(
      "scheme must be one of " + WEBHDFS_SCHEMES + ", got: " + scheme);
}
return DFSUtilClient.getHaNnWebHdfsAddresses(conf, scheme);

Try / catch

try {
  return DFSUtilClient.getHaNnWebHdfsAddresses(conf, scheme);
} catch (IllegalArgumentException e) {
  // surface a clear 4xx-style error for user-supplied schemes instead of a 500
  throw new BadRequestException("Unsupported webhdfs scheme: " + scheme);
}

Prevention

When it happens

Trigger: Calling getHaNnWebHdfsAddresses with a scheme that is not exactly WebHdfsConstants.WEBHDFS_SCHEME ('webhdfs') or SWEBHDFS_SCHEME ('swebhdfs'): passing URI.getScheme() from an hdfs:// URL, forwarding a user-supplied scheme from a proxy/frontend, or a typo/case difference ('WebHDFS').

Common situations: Custom WebHDFS proxies or tooling that builds NN web-redirect addresses; code paths that reuse one address-resolution helper for both RPC (hdfs://) and WebHDFS URIs; request handlers trusting the scheme from an incoming URL.

Related errors


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