hashicorp/nomad · error
Scaling policy invalid: %s
Error message
Scaling policy invalid: %s
What it means
The task group's scaling policy block failed its own Validate() checks; this error prefixes each individual policy error with 'Scaling policy invalid: ' when the group is validated. The actual cause is described after the prefix (e.g. missing min/max, invalid policy config).
Source
Thrown at nomad/structs/structs.go:7619
}
return mErr.ErrorOrNil()
}
// validateScalingPolicy ensures that the scaling policy has consistent
// min and max, not in conflict with the task group count
func (tg *TaskGroup) validateScalingPolicy(j *Job) error {
if tg.Scaling == nil {
return nil
}
var mErr multierror.Error
err := tg.Scaling.Validate()
if err != nil {
// prefix scaling policy errors
if me, ok := err.(*multierror.Error); ok {
for _, e := range me.Errors {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Scaling policy invalid: %s", e))
}
}
}
if tg.Scaling.Max < int64(tg.Count) {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Scaling policy invalid: task group count must not be greater than maximum count in scaling policy"))
}
if int64(tg.Count) < tg.Scaling.Min && !(j.IsMultiregion() && tg.Count == 0 && j.Region == "global") {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Scaling policy invalid: task group count must not be less than minimum count in scaling policy"))
}
return mErr.ErrorOrNil()
}
// Warnings returns a list of warnings that may be from dubious settings orView on GitHub (pinned to 482b49bf1a)
Solutions
- Read the text after the prefix — it names the exact policy problem
- Ensure the scaling block defines valid min and max (max > 0, min <= max)
- Validate the job locally with `nomad job validate` before submitting
Example fix
// before
scaling {
enabled = true
min = 10
max = 5
}
// after
scaling {
enabled = true
min = 1
max = 5
} Defensive patterns
Strategy: validation
Validate before calling
if pol := group.Scaling; pol != nil {
if pol.Max <= 0 { return errors.New("scaling.max must be > 0") }
if pol.Min > pol.Max { return errors.New("scaling.min must be <= scaling.max") }
} Type guard
func validScaling(p *api.ScalingPolicy) bool {
return p == nil || (p.Max > 0 && p.Min >= 0 && p.Min <= p.Max)
} Prevention
- Run `nomad job validate` in CI before submission
- Use a shared template for scaling blocks with sane min/max defaults
- Read the suffixed detail after 'Scaling policy invalid:' to pinpoint the field
When it happens
Trigger: Submitting a job whose task group has a `scaling` block with invalid content — e.g. min > max, missing max, invalid policy stanza — detected inside tg.Scaling.Validate().
Common situations: Hand-writing scaling blocks without min/max bounds; copy-pasted scaling policies from jobs with different types; enabling APM/target policies with wrong keys.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Task group scaling policy validation failed: %v
- Scaling policy invalid: task group count must not be greater
- Scaling policy invalid: task group count must not be less th
- ErrConnectRequireOneNetwork
- ErrConnectInvalidNetworkMode
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/976c568ce0b6b408.
Report an issue: GitHub.