hashicorp/nomad · error
Task group scaling policy validation failed: %v
Error message
Task group scaling policy validation failed: %v
What it means
This error is produced during Job validation in nomad/structs/structs.go when a task group's scaling policy (`tg.validateScalingPolicy`) fails validation. Nomad wraps the underlying policy error with 'Task group scaling policy validation failed: %v' and appends it to the job-level multierror. It indicates the scaling block (horizontal scaling for the group) is malformed or inconsistent with the job.
Source
Thrown at nomad/structs/structs.go:7312
outer := fmt.Errorf("Task group network validation failed: %v", err)
mErr = multierror.Append(mErr, outer)
}
// Validate task group and task services
if err := tg.validateServices(); err != nil {
outer := fmt.Errorf("Task group service validation failed: %v", err)
mErr = multierror.Append(mErr, outer)
}
// Validate group service script-checks
if err := tg.validateScriptChecksInGroupServices(); err != nil {
outer := fmt.Errorf("Task group service check validation failed: %v", err)
mErr = multierror.Append(mErr, outer)
}
// Validate the scaling policy
if err := tg.validateScalingPolicy(j); err != nil {
outer := fmt.Errorf("Task group scaling policy validation failed: %v", err)
mErr = multierror.Append(mErr, outer)
}
// Validate the tasks
for _, task := range tg.Tasks {
if err := task.Validate(j.Type, tg); err != nil {
outer := fmt.Errorf("Task %s validation failed: %v", task.Name, err)
mErr = multierror.Append(mErr, outer)
}
}
return mErr.ErrorOrNil()
}
func (tg *TaskGroup) validateNetworks() error {
var mErr multierror.Error
portLabels := make(map[string]string)
// host_network -> static port trackingView on GitHub (pinned to 482b49bf1a)
Solutions
- Read the wrapped '%v' detail in the error to identify the exact policy field that failed
- Fix the scaling block so min <= count <= max and all values are non-negative integers
- Remove the scaling block from job types that do not support scaling (e.g. system scheduler jobs)
- Validate the job spec with `nomad job validate <file>` before submitting
- Upgrade/downgrade Nomad client/agent versions so server and spec fields match
Example fix
// before
task "web" {}
scaling {
min = -1
max = 0
}
// after
scaling {
min = 1
max = 10
policy {
cooldown = "1m"
check_idle_delay = "30s"
}
} Defensive patterns
Strategy: validation
Validate before calling
func validateScalingBlock(j *api.Job) error {
var errs error
for _, tg := range j.TaskGroups {
if tg.Scaling == nil { continue }
s := tg.Scaling
if s.Min == nil || s.Max == nil { errs = multierror.Append(errs, fmt.Errorf("group %s: scaling min/max required", *tg.Name)); continue }
if *s.Min < 0 { errs = multierror.Append(errs, fmt.Errorf("group %s: scaling min negative", *tg.Name)) }
if *s.Max < *s.Min { errs = multierror.Append(errs, fmt.Errorf("group %s: scaling max < min", *tg.Name)) }
}
return errs
}
// run before submitting: nomad job validate <file> Type guard
func hasValidScaling(tg *api.TaskGroup) bool {
return tg.Scaling != nil && tg.Scaling.Min != nil && tg.Scaling.Max != nil &&
*tg.Scaling.Min >= 0 && *tg.Scaling.Max >= *tg.Scaling.Min
} Prevention
- Always run `nomad job validate` in CI before job register
- Keep min <= count <= max in generated scaling blocks
- Only add scaling blocks to service jobs (not system/batch)
- Pin the Nomad API/CLI version to the cluster version to avoid unsupported policy fields
When it happens
Trigger: Submitting (job register/plan) a job whose task group has a `scaling` block that: has a negative or non-integer min/max, has max < min, missing required fields, invalid policy `policy` map (e.g. unsupported keys or bad target), or scaling policy on a system/batch job type where scaling is not allowed.
Common situations: Hand-writing HCL with a scaling block and typos in min/max; automating scaling config generation (Terraform nomad_job, CI pipelines) that emits invalid bounds; applying job specs written for newer Nomad versions with fields the current server doesn't accept; adding scaling to a system job.
Related errors
- Task group %s validation failed: %v
- Job type %q does not allow update block
- Job type %q does not allow migrate block
- Task %s validation failed: %v
- Scaling policy invalid: %s
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/47e1e83a7fd4fc38.
Report an issue: GitHub.