hashicorp/nomad · error

task not found

Error message

task not found

What it means

allocRunner.GetTaskDriverCapabilities returns this when the requested taskName is not present in the allocation's task map. The caller (usually an internal exec/task-API path) asked for the driver capabilities of a task that does not exist in this allocation.

Source

Thrown at client/allocrunner/alloc_runner.go:1548

	// Broadcast client alloc to listeners.
	err = ar.allocBroadcaster.Send(alloc)

	return
}

func (ar *allocRunner) GetTaskExecHandler(taskName string) drivermanager.TaskExecHandler {
	tr, ok := ar.tasks[taskName]
	if !ok {
		return nil
	}

	return tr.TaskExecHandler()
}

func (ar *allocRunner) GetTaskDriverCapabilities(taskName string) (*drivers.Capabilities, error) {
	tr, ok := ar.tasks[taskName]
	if !ok {
		return nil, fmt.Errorf("task not found")
	}

	return tr.DriverCapabilities()
}

// AcknowledgeState is called by the client's alloc sync when a given client
// state has been acknowledged by the server
func (ar *allocRunner) AcknowledgeState(a *state.State) {
	ar.stateLock.Lock()
	defer ar.stateLock.Unlock()
	ar.lastAcknowledgedState = a
	ar.persistLastAcknowledgedState(a)
}

// persistLastAcknowledgedState stores the last client state acknowledged by the server
func (ar *allocRunner) persistLastAcknowledgedState(a *state.State) {
	if err := ar.stateDB.PutAcknowledgedState(ar.id, a); err != nil {
		// While any persistence errors are very bad, the worst case scenario

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the exact task name via `nomad alloc status <alloc-id>`
  2. Re-fetch the allocation after job updates to get the current task list
  3. Ensure the allocation ID passed alongside the task name belongs to the right task group
Defensive patterns

Strategy: validation

Validate before calling

alloc, _, err := client.Allocations().Info(ctx, allocID, nil)
if err != nil { return err }
if _, ok := alloc.TaskStates[taskName]; !ok {
  return fmt.Errorf("task %q not in alloc %s", taskName, allocID)
}

Prevention

When it happens

Trigger: Calling GetTaskDriverCapabilities (via the task exec / driver-capabilities lookup path) with a task name that doesn't match any task runner in ar.tasks.

Common situations: Internal exec sessions referencing a stale task name; tooling querying capabilities for a task after an in-place alloc update changed the task list; typo in task name when scripting against the task API.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/1bc8d2af58f41de8. Report an issue: GitHub.