apache/hadoop · error · IllegalArgumentException
Cannot parse nsQuota: {}
Error message
Cannot parse nsQuota: {} What it means
Thrown by HDFS Router-Based Federation's admin CLI: dfsrouteradmin -setQuota parses the token after -nsQuota with Long.parseLong. nsQuota is a namespace quota (a count of files and directories), so only a plain signed 64-bit integer is accepted; the value is validated client-side before any RPC reaches the Router. Any other shape -- binary suffixes, decimals, letters -- raises this IllegalArgumentException.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java:986
/**
* Set quota for a mount table entry.
*
* @param parameters Parameters of the quota.
* @param i Index in the parameters.
*/
private boolean setQuota(String[] parameters, int i) throws IOException {
long nsQuota = HdfsConstants.QUOTA_DONT_SET;
long ssQuota = HdfsConstants.QUOTA_DONT_SET;
String mount = parameters[i++];
while (i < parameters.length) {
if (parameters[i].equals("-nsQuota")) {
i++;
try {
nsQuota = Long.parseLong(parameters[i]);
} catch (Exception e) {
throw new IllegalArgumentException(
"Cannot parse nsQuota: " + parameters[i]);
}
} else if (parameters[i].equals("-ssQuota")) {
i++;
try {
ssQuota = StringUtils.TraditionalBinaryPrefix
.string2long(parameters[i]);
} catch (Exception e) {
throw new IllegalArgumentException(
"Cannot parse ssQuota: " + parameters[i]);
}
} else {
throw new IllegalArgumentException(
"Invalid argument : " + parameters[i]);
}
i++;
}View on GitHub (pinned to 2add963021)
Solutions
- Pass a plain integer for -nsQuota, e.g. -nsQuota 100000 (files/directories count, no unit)
- Put size units on -ssQuota instead, which accepts TraditionalBinaryPrefix values like 100GB, 5t, 2TB
- If the value comes from a script, quote it and assert it matches ^-?[0-9]+$ before invoking the CLI
- To remove quotas use 'hdfs dfsrouteradmin -clrQuota <path>' rather than magic numbers
Example fix
# before hdfs dfsrouteradmin -setQuota /mount -nsQuota 100GB # after hdfs dfsrouteradmin -setQuota /mount -nsQuota 100000 -ssQuota 100GB
Defensive patterns
Strategy: validation
Validate before calling
# shell wrapper: verify -nsQuota value is a plain integer before invoking the CLI NS="$1" if ! [[ "$NS" =~ ^-?[0-9]+$ ]]; then echo "nsQuota must be a plain integer (got: $NS)" >&2; exit 2 fi hdfs dfsrouteradmin -setQuota "$MOUNT" -nsQuota "$NS"
Try / catch
In Java wrappers around RouterAdmin, catch IllegalArgumentException and rethrow with the command usage, since the CLI exits nonzero on the first malformed flag.
Prevention
- Remember -nsQuota takes a bare count; unit suffixes only on -ssQuota
- Quote every variable expanded into the command line
- Dry-run quota commands in a staging mount before production runbooks
When it happens
Trigger: hdfs dfsrouteradmin -setQuota /mount -nsQuota 100GB (suffix belongs to -ssQuota only); -nsQuota 1.5; -nsQuota abc; a value larger than Long.MAX_VALUE; an unquoted shell variable expanding to an empty or malformed token.
Common situations: Users carry over habits from 'hdfs dfsadmin -setSpaceQuota 100g' and paste unit suffixes onto -nsQuota. Scripts that assemble the command from user input or unquoted $VARIABLES also hit it. New RBF operators confusing namespace quota with storage-space quota.
Related errors
- Cannot parse ssQuota: {}
- Invalid argument : {}
- Input quota value should be a positive number.
- Must specify at least one of -nsQuota and -ssQuota.
- "{}" is not a valid value for a quota.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f8aa79e77bdc5f4e.
Report an issue: GitHub.