hashicorp/nomad · error
minimum count must be specified and non-negative
Error message
minimum count must be specified and non-negative
What it means
ScalingPolicy.Validate() requires the `min` count to be a non-negative integer. A negative Min (e.g. the -1 'unset' sentinel) appends this error to the multierror. Min defines the lower bound of the allowed task-group count range.
Source
Thrown at nomad/structs/structs.go:6452
// Check policy type and target
if p.Type == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("missing scaling policy type"))
} else {
mErr.Errors = append(mErr.Errors, p.validateType().Errors...)
}
// Check Min and Max
if p.Max < 0 {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("maximum count must be specified and non-negative"))
} else if p.Max < p.Min {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("maximum count must not be less than minimum count"))
}
if p.Min < 0 {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("minimum count must be specified and non-negative"))
}
return mErr.ErrorOrNil()
}
func (p *ScalingPolicy) validateTargetHorizontal() (mErr multierror.Error) {
if len(p.Target) == 0 {
// This is probably not a Nomad horizontal policy
return
}
// Nomad horizontal policies should have Namespace, Job and TaskGroup
if p.Target[ScalingTargetNamespace] == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("missing target namespace"))
}
if p.Target[ScalingTargetJob] == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("missing target job"))
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Set `min` to zero or a positive integer in the scaling block.
- If you want no effective minimum, use `min = 0`, not a negative number.
- Re-run `nomad job validate` to confirm the whole policy passes.
Example fix
// before
scaling {
min = -1
max = 10
}
// after
scaling {
min = 0
max = 10
} Defensive patterns
Strategy: validation
Validate before calling
if policy.Min < 0 {
return fmt.Errorf("scaling policy min must be non-negative; use 0 for no minimum")
} Prevention
- Default Min to 0 rather than -1 in generated policies.
- Parse HCL with explicit min values; never leave them to struct zero/defaults.
- Run `nomad job validate` before submission.
When it happens
Trigger: Submitting a job with `scaling { min = -1 }`, or constructing a ScalingPolicy via the API with a negative Min left from a default value.
Common situations: Omitting min in generated policy JSON where the struct default is negative; using -1 to mean 'no minimum' in custom tooling; typos in HCL.
Related errors
- missing scaling policy type
- maximum count must be specified and non-negative
- maximum count must not be less than minimum count
- missing target namespace
- missing target job
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/fb63b6f7a8457525.
Report an issue: GitHub.