hashicorp/nomad · error
invalid capacity_max: %v
Error message
invalid capacity_max: %v
What it means
Identical to the capacity_min case but for the `capacity_max` field: parseCapacityBytes failed on the value of `capacity_max` in the volume spec, and csiDecodeVolume wraps the failure as `invalid capacity_max: <reason>`. The value must be a byte size string or empty.
Source
Thrown at command/volume_register_csi.go:83
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)
if !ok {
break
}
var m map[string]anyView on GitHub (pinned to 482b49bf1a)
Solutions
- Use a valid size string such as "10GiB", "2000MB", or a raw byte integer for capacity_max.
- Ensure capacity_max >= capacity_min semantics on the storage backend if both are set.
- Omit capacity_max (or leave it empty) when no maximum is needed.
Example fix
// before capacity_max = "unlimited" // after capacity_max = "100GiB"
Defensive patterns
Strategy: validation
Validate before calling
func validCapacityMax(v string, min string) error {
if v == "" { return nil }
b, err := humanize.ParseBytes(strings.Trim(v, "\""))
if err != nil { return fmt.Errorf("capacity_max %q invalid: %v", v, err) }
m, _ := humanize.ParseBytes(strings.Trim(min, "\""))
if b < m { return fmt.Errorf("capacity_max < capacity_min") }
return nil
} Try / catch
if err != nil {
if strings.HasPrefix(err.Error(), "invalid capacity_max") {
return fmt.Errorf("fix capacity_max to e.g. 100GiB: %v", err)
}
return err
} Prevention
- Never write "unlimited" or "-1" for capacity_max; omit the key instead.
- Keep capacity_max >= capacity_min.
- Share a validated spec template across the team.
When it happens
Trigger: `nomad volume register` with a spec containing capacity_max values humanize.ParseBytes rejects, e.g. "unlimited", "2TBx", "5 gb" with odd spacing like "5 g b".
Common situations: Assuming "unlimited" or "-1" are accepted; typo'd unit suffixes; pasting values with surrounding non-numeric text.
Related errors
- invalid capacity_min: %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/77f9bb47afc0ba9d.
Report an issue: GitHub.