hashicorp/nomad · error
either RequiredBytes or LimitBytes must be set
Error message
either RequiredBytes or LimitBytes must be set
What it means
CapacityRange.Validate in plugins/csi/plugin.go:1028 enforces the CSI spec's requirement that a capacity range must constrain the volume size on at least one bound. If both RequiredBytes and LimitBytes are zero, the range conveys no capacity information, so the request is rejected before reaching the CSI plugin.
Source
Thrown at plugins/csi/plugin.go:1028
vc.AccessType = &csipbv1.VolumeCapability_Mount{Mount: opts}
} else {
vc.AccessType = &csipbv1.VolumeCapability_Block{Block: &csipbv1.VolumeCapability_BlockVolume{}}
}
return vc
}
type CapacityRange struct {
RequiredBytes int64
LimitBytes int64
}
func (c *CapacityRange) Validate() error {
if c == nil {
return nil
}
if c.RequiredBytes == 0 && c.LimitBytes == 0 {
return errors.New("either RequiredBytes or LimitBytes must be set")
}
if c.LimitBytes > 0 && c.LimitBytes < c.RequiredBytes {
return errors.New("LimitBytes cannot be less than RequiredBytes")
}
return nil
}
func (c *CapacityRange) ToCSIRepresentation() *csipbv1.CapacityRange {
if c == nil {
return nil
}
return &csipbv1.CapacityRange{
RequiredBytes: c.RequiredBytes,
LimitBytes: c.LimitBytes,
}
}
type NodeExpandVolumeRequest struct {View on GitHub (pinned to 482b49bf1a)
Solutions
- Set required_bytes (minimum size) and/or limit_bytes (maximum size) in the capacity_range block
- If no capacity constraint is intended, pass a nil CapacityRange rather than a zero-valued one
- Validate the volume spec with nomad volume validate before submission
Example fix
// before
capacity_range {}
// after
capacity_range {
required_bytes = 1073741824
limit_bytes = 2147483648
} Defensive patterns
Strategy: validation
Validate before calling
if cr != nil && cr.RequiredBytes == 0 && cr.LimitBytes == 0 { return errors.New("capacity_range must set required_bytes or limit_bytes") } Type guard
func hasCapacity(c *csi.CapacityRange) bool { return c == nil || c.RequiredBytes != 0 || c.LimitBytes != 0 } Prevention
- Always set required_bytes in volume specs
- Use nomad volume validate before submit
- Don't pass zero-valued structs; pass nil if unconstrained
When it happens
Trigger: Submitting a volume-create or volume-expand (NodeExpandVolumeRequest) request whose capacity_range stanza has neither required_bytes nor limit_bytes set; an empty or omitted capacity_range struct passed non-nil with zero values.
Common situations: Nomad volume spec (HCL/JSON) missing required_bytes under capacity_range; API clients constructing CSI volume requests programmatically and forgetting to set bytes; default-constructed Go structs passed to Validate.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- one of LimitBytes or RequiredBytes must be set if CapacityRa
- max requested capacity (%s) less than or equal to current (%
- missing secret ID
- CSI.ControllerValidateVolume: VolumeID is required
- CSI.ControllerValidateVolume: PluginID is required
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/f19de084999efa85.
Report an issue: GitHub.