apache/hadoop · error · IllegalArgumentException
Invalid storage type(null)
Error message
Invalid storage type(null)
What it means
DFSClient.setQuotaByStorageType requires a concrete StorageType; a null type is rejected immediately with IllegalArgumentException('Invalid storage type(null)'), before quota values are even considered. In practice the null usually arrives from an optional parameter (CLI flag, JSON field, config key) that was omitted and never defaulted.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java:2679
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);
}
}
/**
* set the modification and access time of a file.View on GitHub (pinned to 2add963021)
Solutions
- Require the type at your boundary: validate non-null (and one of DISK/SSD/ARCHIVE/RAM_DISK/NVDIMM) before invoking the client.
- Fail fast with a clear message listing valid types instead of letting null reach the RPC layer.
- Fix the caller that dropped or never parsed the parameter.
Example fix
// before client.setQuotaByStorageType(dir, type, quota); // type == null // IllegalArgumentException: Invalid storage type(null) // after Objects.requireNonNull(type, 'storage type must be one of DISK, SSD, ARCHIVE, RAM_DISK, NVDIMM'); client.setQuotaByStorageType(dir, type, quota);
Defensive patterns
Strategy: validation
Validate before calling
if (type == null) {
throw new IllegalArgumentException("storage type required: DISK, SSD, ARCHIVE, RAM_DISK, NVDIMM");
}
client.setQuotaByStorageType(dir, type, quota); Try / catch
catch (IllegalArgumentException e) {
if (e.getMessage().contains("storage type")) {
// missing parameter upstream: reject the request at your API boundary
} else { throw e; }
} Prevention
- Make storage type a required parameter in your tooling, validated at parse time.
- Avoid Optional/null plumbing for enum parameters; use explicit parsed request objects.
- Unit-test the null path of every wrapper around quota APIs.
When it happens
Trigger: Calling setQuotaByStorageType(src, null, quota); a CLI layer mapping a missing -storageType flag to null; deserialization of requests where the type field is absent; test code passing an unset variable.
Common situations: Custom admin tooling fronting quota APIs; REST/JSON drivers where 'storageType' is optional but this call requires it; refactors that change the parameter order or type.
Related errors
- Invalid values for quota :{}
- Quota by storage type : type on path : pathName is exceeded.
- "Failed to set quota by storage type because either" + DFS_Q
- Storage type {} is not available. Available storage types ar
- Invalid values for quota : {} and {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c4742d155579790e.
Report an issue: GitHub.