apache/hadoop · error · IllegalArgumentException

Invalid values for quota : ${namespaceQuota} and ${storagesp

Error message

Invalid values for quota : ${namespaceQuota} and ${storagespaceQuota}

What it means

Client-side fast-fail sanity check in WebHdfsFileSystem.setQuota before sending the SETQUOTA REST request: the namespace quota must be positive or HdfsConstants.QUOTA_RESET (-1), and the storage-space quota must be non-negative or QUOTA_RESET. An IllegalArgumentException is thrown locally rather than bothering the NameNode with an invalid request. Zero is not a legal quota for either dimension in this check.

Source

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

    final HttpOpParam.Op op = GetOpParam.Op.GETQUOTAUSAGE;
    return new FsPathResponseRunner<QuotaUsage>(op, p) {
      @Override
      QuotaUsage decodeResponse(Map<?, ?> json) {
        return JsonUtilClient.toQuotaUsage(json);
      }
    }.run();
  }

  @Override
  public void setQuota(Path p, final long namespaceQuota,
      final long storagespaceQuota) throws IOException {
    // sanity check
    if ((namespaceQuota <= 0 &&
        namespaceQuota != HdfsConstants.QUOTA_RESET) ||
        (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) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a positive namespace quota and a non-negative storage quota
  2. To clear a quota pass HdfsConstants.QUOTA_RESET (-1) for that dimension; to leave it unchanged pass HdfsConstants.QUOTA_DONT_SET (Long.MAX_VALUE), which also passes this check
  3. Validate values at the call site before invoking setQuota (mirror the check below) so callers get your own error message

Example fix

// before
fs.setQuota(path, 0, 1024L * 1024 * 1024); // 0 is invalid here
// after: clear the namespace quota, set a 1 GB space quota
fs.setQuota(path, HdfsConstants.QUOTA_RESET, 1024L * 1024 * 1024);
Defensive patterns

Strategy: validation

Validate before calling

static void checkQuotaArgs(long nsQuota, long ssQuota) {
  if ((nsQuota <= 0 && nsQuota != HdfsConstants.QUOTA_RESET)
      || (ssQuota < 0 && ssQuota != HdfsConstants.QUOTA_RESET)) {
    throw new IllegalArgumentException("ns=" + nsQuota + ", ss=" + ssQuota
        + ": use positive quotas, HdfsConstants.QUOTA_RESET to clear,");
  }
}

Try / catch

try {
  fs.setQuota(p, ns, ss);
} catch (IllegalArgumentException e) {
  // client-side reject: fix the numbers, do not retry
  throw new ConfigurationException("Bad quota values: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling fs.setQuota(path, ns, ss) with namespaceQuota <= 0 (other than -1) or storagespaceQuota < 0 (other than -1), e.g. setQuota(p, 0, 1073741824) or setQuota(p, -5, -5).

Common situations: Passing 0 intending 'no quota' (use QUOTA_RESET to clear or QUOTA_DONT_SET to leave unchanged); arithmetic that underflows into negatives; porting CLI 'dfsadmin -setQuota -1' semantics but writing 0; code paths that default unset longs to 0.

Related errors


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