apache/hadoop · error · IllegalArgumentException
"{}" is not a valid value for a quota.
Error message
"{}" is not a valid value for a quota. What it means
Constructor argument parser for `hdfs dfsadmin -setSpaceQuota <quota> <path>...`. The first positional argument is parsed with StringUtils.TraditionalBinaryPrefix.string2long, which accepts plain integers and binary-prefixed values (1k, 1m, 1g, 1t, 1p). Anything else raises NumberFormatException, rethrown as IllegalArgumentException('"<str>" is not a valid value for a quota.') with the offending string quoted for easy spotting.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java:327
"\t\t- DISK\n" +
"\t\t- SSD\n" +
"\t\t- ARCHIVE\n" +
"\t\t- PROVIDED\n" +
"\t\t- NVDIMM";
private long quota; // the quota to be set
private StorageType type;
/** Constructor */
SetSpaceQuotaCommand(String[] args, int pos, Configuration conf) {
super(conf);
CommandFormat c = new CommandFormat(2, Integer.MAX_VALUE);
List<String> parameters = c.parse(args, pos);
String str = parameters.remove(0).trim();
try {
quota = StringUtils.TraditionalBinaryPrefix.string2long(str);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("\"" + str + "\" is not a valid value for a quota.");
}
String storageTypeString =
StringUtils.popOptionWithArgument("-storageType", parameters);
if (storageTypeString != null) {
try {
this.type = StorageType.parseStorageType(storageTypeString);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Storage type "
+ storageTypeString
+ " is not available. Available storage types are "
+ StorageType.getTypesSupportingQuota());
}
}
this.args = parameters.toArray(new String[parameters.size()]);
}
/** Check if a command is the setQuota command
* View on GitHub (pinned to 2add963021)
Solutions
- Pass a plain byte count or a binary-prefix value: 1099511627776 or 1t
- Normalize user input before invoking the CLI: strip commas/spaces, reject non suffix values
- To remove a quota use hdfs dfsadmin -clrSpaceQuota <path>
- Validate with TraditionalBinaryPrefix.string2long() in a try/catch before spawning the command
Example fix
# before $ hdfs dfsadmin -setSpaceQuota 1TB /data # IllegalArgumentException: "1TB" is not a valid value for a quota. # after $ hdfs dfsadmin -setSpaceQuota 1t /data $ hdfs dfsadmin -setSpaceQuota 1099511627776 /data # equivalent plain bytes
Defensive patterns
Strategy: validation
Validate before calling
static long parseQuota(String raw) {
try {
return StringUtils.TraditionalBinaryPrefix.string2long(raw.trim());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("'" + raw + "' is not a quota; use 1024, 10m, 1t ...", e);
}
} Type guard
static boolean isValidQuota(String s) {
try { StringUtils.TraditionalBinaryPrefix.string2long(s.trim()); return true; }
catch (NumberFormatException e) { return false; }
} Try / catch
catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("not a valid value for a quota"))
return usage("quota must be a long or binary-prefixed value like 1t");
throw e;
} Prevention
- Normalize user input before spawning dfsadmin: strip commas, reject unit suffixes with 'B'
- Remember only k/m/g/t/p (and plain longs) parse — 1MB, 1TB, 'none' do not
- Use -clrSpaceQuota to remove a quota, never a magic value
When it happens
Trigger: hdfs dfsadmin -setSpaceQuota abc /data; -setSpaceQuota 10XB /data (bad suffix); -setSpaceQuota 1,000,000 /data (commas); shell quoting that passes an empty string as the first parameter.
Common situations: Scripts feeding human-formatted numbers or SI units (1MB, 10GB with 'B'); users trying 'none' or 'unlimited' (not valid here — use -clrSpaceQuota); copy-paste of nameservice quotas from a doc into the CLI.
Related errors
- Storage type {} is not available. Available storage types ar
- Failed to convert "{}" to RollingUpgradeAction
- Cannot parse nsQuota: {}
- Cannot parse ssQuota: {}
- Unable to parse relative time value of {}: {} is not a numbe
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/dc1299672ec3aca0.
Report an issue: GitHub.