hashicorp/nomad · error
missing target group
Error message
missing target group
What it means
ScalingPolicy.validateTargetHorizontal() requires a non-empty `TaskGroup` key in the target map for horizontal policies. The group identifies which task group's count is scaled; omission triggers this error.
Source
Thrown at nomad/structs/structs.go:6472
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{
ID: p.ID,
Type: p.Type,
Target: make(map[string]string),View on GitHub (pinned to 482b49bf1a)
Solutions
- Add `group = "<task-group-name>"` inside the policy's target block.
- If the policy is defined inline in the job's scaling block, prefer the inline form so Nomad infers the target keys.
- For the API path, set Target["TaskGroup"] explicitly in the JSON payload.
Example fix
// before
target {
namespace = "default"
job = "web"
}
// after
target {
namespace = "default"
job = "web"
group = "frontend"
} Defensive patterns
Strategy: validation
Validate before calling
if policy.Target["TaskGroup"] == "" {
return fmt.Errorf("horizontal policy target missing TaskGroup")
} Prevention
- Set `group` explicitly in every horizontal policy target block.
- Prefer inline scaling blocks within the task group so the group is inferred.
- Add the TaskGroup key check to any script that builds scaling policy payloads.
When it happens
Trigger: Submitting a horizontal scaling policy whose target block includes `namespace` and `job` but omits `group`, or an API-created Target map without the ScalingTargetGroup key.
Common situations: Templates that stop at namespace/job; tooling that fills target keys selectively; users assuming the policy's owning group is inferred automatically when written inside the job file (inline scaling blocks infer it, but standalone policy API objects must set it).
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 job
- 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/517f426096aea71f.
Report an issue: GitHub.