hashicorp/nomad · error
missing target job
Error message
missing target job
What it means
ScalingPolicy.validateTargetHorizontal() requires a non-empty `Job` key in the target map for horizontal policies. The job identifies which job the scaling policy applies to; its absence triggers this error alongside (potentially) the namespace/group checks.
Source
Thrown at nomad/structs/structs.go:6469
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"))
}
if p.Target[ScalingTargetGroup] == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("missing target group"))
}
return
}
// Diff indicates whether the specification for a given scaling policy has changed
func (p *ScalingPolicy) Diff(p2 *ScalingPolicy) bool {
copy := *p2
copy.ID = p.ID
copy.CreateIndex = p.CreateIndex
copy.ModifyIndex = p.ModifyIndex
return !reflect.DeepEqual(*p, copy)
}
func (p *ScalingPolicy) Stub() *ScalingPolicyListStub {
stub := &ScalingPolicyListStub{View on GitHub (pinned to 482b49bf1a)
Solutions
- Add `job = "<job-name>"` inside the policy's target block.
- Ensure the job name matches the job the policy is registered under.
- Re-validate the policy after adding the key.
Example fix
// before
target {
namespace = "default"
group = "frontend"
}
// after
target {
namespace = "default"
job = "web"
group = "frontend"
} Defensive patterns
Strategy: validation
Validate before calling
if policy.Target["Job"] == "" {
return fmt.Errorf("horizontal policy target missing Job")
} Prevention
- Set `job` explicitly in every horizontal policy target block.
- When renaming jobs, update target.job in registered scaling policies.
- Check for all three target keys (Namespace/Job/TaskGroup) in policy-generation tooling.
When it happens
Trigger: Submitting a horizontal scaling policy with a target block that has `namespace` and `group` but omits `job`, or an API Target map missing the ScalingTargetJob key.
Common situations: Copy-pasting policy templates that omit the job key; tooling building Target maps from partial context; renaming a job and dropping the key during refactoring.
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
- missing target namespace
- missing target group
- missing scaling policy type
- maximum count must be specified and non-negative
- maximum count must not be less than minimum count
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4e5744d6e01bc1ca.
Report an issue: GitHub.