hashicorp/nomad · error
invalid host_volumes limit: %v
Error message
invalid host_volumes limit: %v
What it means
This error wraps a failure to parse the `host_volumes` storage-resource quota field in a Nomad quota specification HCL/JSON file. parseStorageResource reads the `host_volumes` key of the quota's storage resources and passes its value to parseQuotaMegabytes; any parse failure (bad unit, bad type) is wrapped with this message so the user knows which quota field is at fault. It is a user-input validation error in the `nomad quota apply` command.
Source
Thrown at command/quota_apply.go:351
}
block := storageBlocks.Items[0]
valid := []string{"variables", "host_volumes"}
if err := helper.CheckHCLKeys(block.Val, valid); err != nil {
return nil, err
}
var m map[string]any
if err := hcl.DecodeObject(&m, block.Val); err != nil {
return nil, err
}
variablesLimit, err := parseQuotaMegabytes(m["variables"])
if err != nil {
return nil, fmt.Errorf("invalid variables limit: %v", err)
}
hostVolumesLimit, err := parseQuotaMegabytes(m["host_volumes"])
if err != nil {
return nil, fmt.Errorf("invalid host_volumes limit: %v", err)
}
return &api.QuotaStorageResources{
VariablesMB: variablesLimit,
HostVolumesMB: hostVolumesLimit,
}, nil
}
func parseQuotaMegabytes(raw any) (int, error) {
switch val := raw.(type) {
case string:
b, err := humanize.ParseBytes(val)
if err != nil {
return 0, fmt.Errorf("could not parse value as bytes: %v", err)
}
return int(b >> 20), nil
case int:
return val, nilView on GitHub (pinned to 482b49bf1a)
Solutions
- Fix the host_volumes value in the quota file to a valid byte string (e.g. "500MB", "1GiB", "2GB") or an integer of megabytes.
- Check the wrapped inner error (%v) for the exact humanize.ParseBytes complaint and correct the offending token.
- Validate the quota file with `nomad quota apply` on a staging cluster or use a JSON/HCL linter before applying.
- If an integer is intended, ensure it is an unquoted integer representing megabytes, not a quoted string with an unsupported format.
Example fix
// before
resources {
host_volumes = "50 MBB"
}
// after
resources {
host_volumes = "500MB"
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the host_volumes value before applying the quota
v, ok := quota.Resources["host_volumes"]
switch t := v.(type) {
case nil, int:
// ok
case string:
if _, err := humanize.ParseBytes(t); err != nil {
return fmt.Errorf("invalid host_volumes limit %q: %w", t, err)
}
default:
return fmt.Errorf("host_volumes must be string or int, got %T", v)
} Type guard
func validQuotaSize(v any) bool {
switch t := v.(type) {
case nil, int:
return true
case string:
_, err := humanize.ParseBytes(t)
return err == nil
default:
return false
}
} Prevention
- Use documented units: MB/GB/MiB/GiB suffixes accepted by go-humanize
- Keep size values as quoted strings with units or unquoted megabyte integers, never bools/floats/lists
- Lint quota HCL/JSON in CI before running nomad quota apply
- Copy values from `nomad quota inspect` output of a working quota
When it happens
Trigger: Running `nomad quota apply` with a quota file whose `quota.limit`-style `host_volumes` entry is a string that humanize.ParseBytes cannot parse (e.g. "10GB/s", "ten mb", "", or a unit typo like "50 MBB"), or a value of an unsupported type (e.g. bool/float in JSON).
Common situations: Hand-edited quota HCL files with unit typos ("1000 mb " with stray characters), JSON quota specs where host_volumes was set to true/false or a float, copying examples from docs for other fields and leaving an invalid value.
Related errors
- error parsing: root should be an object
- limit should be an object
- only one 'region_limit' block allowed per limit
- resource: should be an object
- invalid variables limit: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/8f45803f5907e1ae.
Report an issue: GitHub.