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();
}
@OverrideView on GitHub (pinned to 2add963021)
Solutions
- Pass a positive quota value for the storage type
- To remove the type quota pass HdfsConstants.QUOTA_RESET (-1)
- 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
- Treat -1 as the only legal non-positive quota value
- Default unset numeric config to QUOTA_RESET explicitly, never 0
- Unit-test quota plumbing with -1, 0, 1, Long.MAX_VALUE
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
- Invalid values for quota :{}
- Invalid storage type(null)
- Invalid values for quota : ${namespaceQuota} and ${storagesp
- Invalid storage type (null)
- Quota for storage type '${type}' is not supported
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/02c1fb1e589ca651.
Report an issue: GitHub.