apache/hadoop · error · IllegalArgumentException

Invalid storage type (null)

Error message

Invalid storage type (null)

What it means

Null guard in WebHdfsFileSystem.setQuotaByStorageType: the StorageType argument must not be null, otherwise IllegalArgumentException('Invalid storage type (null)') is thrown before any request is issued. It protects later code (type.name(), type.supportTypeQuota()) from an NPE and gives a clearer message.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java:2080

          namespaceQuota + " and " + storagespaceQuota);
    }

    statistics.incrementWriteOps(1);
    storageStatistics.incrementOpCounter(OpType.SET_QUOTA_USAGE);

    final HttpOpParam.Op op = PutOpParam.Op.SETQUOTA;
    new FsPathRunner(op, p, new NameSpaceQuotaParam(namespaceQuota),
        new StorageSpaceQuotaParam(storagespaceQuota)).run();
  }

  @Override
  public void setQuotaByStorageType(Path path, StorageType type, long quota)
      throws IOException {
    if (quota <= 0 && quota != HdfsConstants.QUOTA_RESET) {
      throw new IllegalArgumentException("Invalid values for quota :" + quota);
    }
    if (type == null) {
      throw new IllegalArgumentException("Invalid storage type (null)");
    }
    if (!type.supportTypeQuota()) {
      throw new IllegalArgumentException(
          "Quota for storage type '" + type.toString() + "' is not supported");
    }

    statistics.incrementWriteOps(1);
    storageStatistics.incrementOpCounter(OpType.SET_QUOTA_BYTSTORAGEYPE);

    final HttpOpParam.Op op = PutOpParam.Op.SETQUOTABYSTORAGETYPE;
    new FsPathRunner(op, path, new StorageTypeParam(type.name()),
        new StorageSpaceQuotaParam(quota)).run();
  }

  @Override
  public MD5MD5CRC32FileChecksum getFileChecksum(final Path p
  ) throws IOException {
    statistics.incrementReadOps(1);

View on GitHub (pinned to 2add963021)

Solutions

  1. Resolve the StorageType before the call and fail with a clear message if it cannot be parsed (StorageType.valueOf throws on unknown names; handle that too)
  2. Default to a sensible type (commonly StorageType.DISK) when configuration omits it
  3. Add an Objects.requireNonNull(type, "storage type") at your own API boundary

Example fix

// before
StorageType t = parseType(conf.get("my.quota.type")); // may return null
fs.setQuotaByStorageType(path, t, quota);
// after
StorageType t = Optional.ofNullable(parseType(conf.get("my.quota.type")))
    .orElseThrow(() -> new IllegalArgumentException("my.quota.type missing/unknown"));
fs.setQuotaByStorageType(path, t, quota);
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(type, "storage type must not be null");
StorageType t = StorageType.valueOf(
    Objects.requireNonNull(rawTypeName, "storage type config missing")
        .trim().toUpperCase(Locale.ROOT));
fs.setQuotaByStorageType(path, t, quota);

Type guard

static boolean isUsableStorageType(StorageType t) {
  return t != null;
}

Prevention

When it happens

Trigger: Calling fs.setQuotaByStorageType(path, null, quota), typically because a type variable came from configuration parsing or a map lookup that returned null.

Common situations: StorageType parsed from a config key that is absent (custom parse returning null instead of throwing); Map<String,StorageType> miss; optional parameters wired straight through from CLI/JSON into the API.

Related errors


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