hashicorp/nomad · error
invalid capacity_min: %v
Error message
invalid capacity_min: %v
What it means
After decoding the HCL volume spec, csiDecodeVolume extracts the `capacity_min` block/value and runs parseCapacityBytes on it. If that parser fails (the value is not an empty string and not a humanize-parseable byte size), the error is wrapped as `invalid capacity_min: <reason>`. It indicates the `capacity_min` field in the volume spec is not a valid byte-capacity value.
Source
Thrown at command/volume_register_csi.go:78
}
// Need to manually parse these fields
delete(m, "capability")
delete(m, "mount_options")
delete(m, "capacity_max")
delete(m, "capacity_min")
delete(m, "topology_request")
delete(m, "type")
// Decode the rest
err = mapstructure.WeakDecode(m, vol)
if err != nil {
return nil, err
}
capacityMin, err := parseCapacityBytes(list.Filter("capacity_min"))
if err != nil {
return nil, fmt.Errorf("invalid capacity_min: %v", err)
}
vol.RequestedCapacityMin = capacityMin
capacityMax, err := parseCapacityBytes(list.Filter("capacity_max"))
if err != nil {
return nil, fmt.Errorf("invalid capacity_max: %v", err)
}
vol.RequestedCapacityMax = capacityMax
capObj := list.Filter("capability")
if len(capObj.Items) > 0 {
for _, o := range capObj.Elem().Items {
valid := []string{"access_mode", "attachment_mode"}
if err := helper.CheckHCLKeys(o.Val, valid); err != nil {
return nil, err
}
ot, ok := o.Val.(*ast.ObjectType)View on GitHub (pinned to 482b49bf1a)
Solutions
- Set capacity_min to a value parseable by dustin/go-humanize.ParseBytes, e.g. "1GiB", "500MB", or a plain integer of bytes.
- Check for typos or stray characters in the value (commas, units per second, placeholder text).
- Remove the capacity_min key entirely if a default is acceptable (an empty value parses to 0).
Example fix
// before capacity_min = "10 GB/s" // after capacity_min = "10GiB"
Defensive patterns
Strategy: validation
Validate before calling
// pre-validate capacity_min locally
func validCapacity(v string) bool {
if v == "" { return true }
_, err := humanize.ParseBytes(strings.Trim(v, "\""))
return err == nil
}
if !validCapacity(spec.CapacityMin) {
return fmt.Errorf("capacity_min %q is not a valid byte size", spec.CapacityMin)
} Try / catch
vol, err := csiDecodeVolume(f)
if err != nil {
var inv *fmt.Errorf
if strings.HasPrefix(err.Error(), "invalid capacity_min") {
return fmt.Errorf("fix capacity_min to e.g. 10GiB: %v", err)
}
return err
} Prevention
- Always use humanize-compatible units (KB/MB/GB or KiB/MiB/GiB).
- Avoid commas, spaces, and placeholder text in capacity values.
- Test specs against humanize.ParseBytes in CI before registering.
When it happens
Trigger: `nomad volume register` with a spec whose `capacity_min` is set to a non-numeric or non-size string, e.g. capacity_min = "big", "10 gb/s", "1OGB" (letter O), or a nested block where a literal is expected.
Common situations: Typos in unit suffixes; copying examples with placeholder values; locale-formatted numbers like "1,000 MB"; unit confusion between humanize's accepted suffixes (KB/MB/GB, kiB/MiB/GiB) and free-form text.
Related errors
- invalid capacity_max: %v
- invalid capability: %v
- error parsing: root should be an object
- missing secret ID
- CSI.ControllerValidateVolume: VolumeID is required
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/1f13de37b5d0ca12.
Report an issue: GitHub.