hashicorp/nomad · error
Scaling policy invalid: task group count must not be greater
Error message
Scaling policy invalid: task group count must not be greater than maximum count in scaling policy
What it means
TaskGroup validation rejects a job where the group's static `count` exceeds the `max` declared in its scaling policy, since the scheduler would then run allocations outside the policy's allowed range.
Source
Thrown at nomad/structs/structs.go:7626
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 or
// deprecation warnings.
func (tg *TaskGroup) Warnings(j *Job) error {
var mErr multierror.Error
// Validate the update strategy
if u := tg.Update; u != nil {
// Check the counts are appropriateView on GitHub (pinned to 482b49bf1a)
Solutions
- Lower the group `count` to be <= scaling max
- Raise `max` in the scaling block to at least the desired count
- Remove the static count and let the scaling policy govern instances
Example fix
// before
count = 5
scaling { min = 1 max = 3 }
// after
count = 3
scaling { min = 1 max = 3 } Defensive patterns
Strategy: validation
Validate before calling
if g.Scaling != nil && int64(g.Count) > g.Scaling.Max {
return fmt.Errorf("count %d exceeds scaling.max %d", g.Count, g.Scaling.Max)
} Type guard
func countWithinMax(g *api.TaskGroup) bool {
return g.Scaling == nil || int64(g.Count) <= g.Scaling.Max
} Prevention
- Keep one source of truth for count: prefer the scaling policy
- Audit scaling max when changing count manually
- Remember `nomad job scale` interactions with static count
When it happens
Trigger: Submitting a job with `count = N` in the task group while the `scaling` block has `max < N` (e.g. count=5, scaling max=3).
Common situations: Manually raising `count` (or via `nomad job scale` interplay) after adding a scaling policy; copy-pasting a scaling block from another group with a lower max.
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: %s
- 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/c55825fa6325cdf1.
Report an issue: GitHub.