apache/hadoop · error · IllegalArgumentException

Invalid values for quota :{}

Error message

Invalid values for quota :{}

What it means

DFSClient.setQuotaByStorageType validates its single quota the same way as the pair API: it must be positive or one of the sentinels HdfsConstants.QUOTA_DONT_SET (Long.MAX_VALUE) / QUOTA_RESET (-1). Because the sentinel is Long.MAX_VALUE, common stand-ins like 0 or -2 are rejected client-side with IllegalArgumentException.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java:2675

          FileNotFoundException.class,
          NSQuotaExceededException.class,
          DSQuotaExceededException.class,
          QuotaByStorageTypeExceededException.class,
          UnresolvedPathException.class,
          SnapshotAccessControlException.class);
    }
  }

  /**
   * Sets or resets quotas by storage type for a directory.
   * @see ClientProtocol#setQuota(String, long, long, StorageType)
   */
  void setQuotaByStorageType(String src, StorageType type, long quota)
      throws IOException {
    checkOpen();
    if (quota <= 0 && quota != HdfsConstants.QUOTA_DONT_SET &&
        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(
          "Don't support Quota for storage type : " + type.toString());
    }
    try (TraceScope ignored = newPathTraceScope("setQuotaByStorageType", src)) {
      namenode.setQuota(src, HdfsConstants.QUOTA_DONT_SET, quota, type);
    } catch (RemoteException re) {
      throw re.unwrapRemoteException(AccessControlException.class,
          FileNotFoundException.class,
          QuotaByStorageTypeExceededException.class,
          UnresolvedPathException.class,
          SnapshotAccessControlException.class);
    }

View on GitHub (pinned to 2add963021)

Solutions

  1. Use the sentinels explicitly: positive to set, HdfsConstants.QUOTA_RESET (-1) to clear, HdfsConstants.QUOTA_DONT_SET (Long.MAX_VALUE) to leave unchanged.
  2. Validate the parsed value at your config/CLI boundary before it reaches the client (positive or exactly -1 / Long.MAX_VALUE).
  3. Audit serialization of sentinel values through your config store.

Example fix

// before
client.setQuotaByStorageType(dir, StorageType.SSD, quota); // quota = 0 or -2

// after
long q = (quota <= 0) ? HdfsConstants.QUOTA_RESET : quota; // set: >0, reset: -1
client.setQuotaByStorageType(dir, StorageType.SSD, q);
Defensive patterns

Strategy: validation

Validate before calling

boolean ok = quota > 0 || quota == HdfsConstants.QUOTA_DONT_SET || quota == HdfsConstants.QUOTA_RESET;
if (!ok) {
  throw new IllegalArgumentException("storage-type quota out of range: " + quota);
}

Try / catch

catch (IllegalArgumentException e) {
  // report the rejected quota value and the intended storage type
}

Prevention

When it happens

Trigger: Calling setQuotaByStorageType with 0 (expecting 'unlimited'), -2, or an underflowed computed value; tools that parse quota strings and default missing values to 0; config round-trips losing the Long.MAX_VALUE sentinel.

Common situations: Storage-type quota automation (SSD/ARCHIVE tiering policies) with custom frontends; scripts migrating quota settings between clusters; JSON/YAML configs where Long.MAX_VALUE got serialized incorrectly.

Related errors


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