hashicorp/nomad · error
failed to lookup task group %q
Error message
failed to lookup task group %q
What it means
NewAllocRunner validates that the allocation's TaskGroup exists in its Job before constructing the runner. This error means alloc.TaskGroup named a group that alloc.Job does not contain — the allocation and its job definition are inconsistent.
Source
Thrown at client/allocrunner/alloc_runner.go:239
// partitions is an interface for managing cpuset partitions
partitions cinterfaces.CPUPartitions
// widsigner signs workload identities
widsigner widmgr.IdentitySigner
// widmgr manages workload identity signatures
widmgr widmgr.IdentityManager
// users manages a pool of dynamic workload users
users dynamic.Pool
}
// NewAllocRunner returns a new allocation runner.
func NewAllocRunner(config *config.AllocRunnerConfig) (interfaces.AllocRunner, error) {
alloc := config.Alloc
tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)
if tg == nil {
return nil, fmt.Errorf("failed to lookup task group %q", alloc.TaskGroup)
}
ar := &allocRunner{
id: alloc.ID,
alloc: alloc,
clientConfig: config.ClientConfig,
clientBaseLabels: config.BaseLabels,
consulServicesHandler: config.ConsulServices,
consulProxiesClientFunc: config.ConsulProxiesFunc,
vaultClientFunc: config.VaultFunc,
tasks: make(map[string]*taskrunner.TaskRunner, len(tg.Tasks)),
waitCh: make(chan struct{}),
destroyCh: make(chan struct{}),
shutdownCh: make(chan struct{}),
state: &state.State{},
stateDB: config.StateDB,
stateUpdater: config.StateUpdater,
taskStateUpdatedCh: make(chan struct{}, 1),View on GitHub (pinned to 482b49bf1a)
Solutions
- Verify alloc.Job and alloc.TaskGroup are both populated before calling NewAllocRunner: ensure the job was fetched/loaded with all task groups (LookupTaskGroup name match is exact)
- Redeploy the job so a fresh, consistent allocation replaces the corrupt one
- Inspect the client state store entry for this alloc — if the Job is missing groups, restore from a valid job file (`nomad job revert` or re-run the job)
- If writing integrations/tests, always set Alloc.TaskGroup to a group name that exists in Alloc.Job.TaskGroups
Example fix
// before
config.Alloc = alloc // Job not populated -> failed to lookup task group
// after
job, err := client.Jobs().Info(alloc.JobID)
if err != nil { return err }
alloc.Job = job
if alloc.Job.LookupTaskGroup(alloc.TaskGroup) == nil {
return fmt.Errorf("alloc %s references unknown task group %q", alloc.ID, alloc.TaskGroup)
} Defensive patterns
Strategy: validation
Validate before calling
// Before constructing an alloc runner, validate consistency
if alloc.Job == nil || alloc.Job.LookupTaskGroup(alloc.TaskGroup) == nil {
return fmt.Errorf("alloc %s: job missing task group %q", alloc.ID, alloc.TaskGroup)
} Try / catch
ar, err := NewAllocRunner(cfg)
if err != nil {
if strings.Contains(err.Error(), "failed to lookup task group") {
// re-fetch job, restore state, or mark alloc corrupt
}
return err
} Prevention
- Always populate Alloc.Job from a full job spec before building runners
- Never hand-edit or truncate client state store entries
- Match TaskGroup names exactly (case-sensitive) when crafting allocs
- After job spec renames, redeploy rather than reusing old alloc structs
When it happens
Trigger: Creating an AllocRunner with a config whose Alloc.Job was not fully populated (e.g. job plan/restore path omitted task groups) or whose TaskGroup name does not match any group in the embedded job; callers include the test suite and internal restore paths.
Common situations: Custom tooling or upgrades injecting/stripping jobs from state (e.g. restoring an alloc whose job spec was truncated); a stale alloc referencing a job version whose group was renamed; hand-crafted alloc structs in automation/scripts.
Related errors
- Reschedule policy has unlimited attempts enabled and a low d
- Lock delay and TTL must be positive
- failed creating runner for task %q: %v
- https_handshake_timeout must be >= 0
- http_max_conns_per_client must be >= 0
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e310b3f9f7e5f50f.
Report an issue: GitHub.