apache/hadoop · error · IllegalArgumentException

Invalid values for quota :${quota}

Error message

Invalid values for quota :${quota}

What it means

Fast-fail check in WebHdfsFileSystem.setQuotaByStorageType: a per-storage-type quota must be positive or equal to HdfsConstants.QUOTA_RESET (-1); anything else (0, negative values other than -1) throws IllegalArgumentException before the SETQUOTABYSTORAGETYPE request is sent. It mirrors the NameNode's own quota validation on the client side.

Source

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

        (storagespaceQuota < 0 &&
            storagespaceQuota != HdfsConstants.QUOTA_RESET)) {
      throw new IllegalArgumentException("Invalid values for quota : " +
          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

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a positive quota value for the storage type
  2. To remove the type quota pass HdfsConstants.QUOTA_RESET (-1)
  3. Validate quota > 0 || quota == HdfsConstants.QUOTA_RESET at the call site before the API call

Example fix

// before
fs.setQuotaByStorageType(path, StorageType.SSD, 0);
// after: clear the SSD quota
fs.setQuotaByStorageType(path, StorageType.SSD, HdfsConstants.QUOTA_RESET);
Defensive patterns

Strategy: validation

Validate before calling

static boolean isValidTypeQuota(long quota) {
  return quota > 0 || quota == HdfsConstants.QUOTA_RESET;
}

if (!isValidTypeQuota(quota)) {
  throw new IllegalArgumentException("quota must be > 0 or QUOTA_RESET(-1), got " + quota);
}

Prevention

When it happens

Trigger: Calling fs.setQuotaByStorageType(path, type, quota) with quota == 0 or quota < 0 && quota != -1, e.g. setQuotaByStorageType(p, StorageType.SSD, 0).

Common situations: Using 0 to mean 'remove the type quota' instead of QUOTA_RESET; uninitialized long fields defaulting to 0; porting scripts that pass -1 for 'unlimited' but a -2 or 0 slips through from arithmetic.

Related errors


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