hashicorp/nomad · error

task %s not found in allocation %s

Error message

task %s not found in allocation %s

What it means

Returned by the client exec endpoint when an action is requested: the named task exists in the request but alloc.LookupTask cannot find it inside the allocation, meaning the task name does not belong to that allocation.

Source

Thrown at client/alloc_endpoint.go:308

		return nil, nstructs.ErrPermissionDenied
	}

	// Validate the arguments
	if req.Task == "" {
		return new(int64(400)), taskNotPresentErr
	}

	if req.JobID != "" && req.JobID != alloc.JobID {
		return new(int64(http.StatusBadRequest)),
			fmt.Errorf("job %s does not have allocation %s", req.JobID, req.AllocID)
	}

	// If an action is present, go find the command and args
	if req.Action != "" {
		task := alloc.LookupTask(req.Task)
		if task == nil {
			return new(int64(http.StatusBadRequest)),
				fmt.Errorf("task %s not found in allocation %s", req.Task, alloc.ID)
		}
		jobAction := task.GetAction(req.Action)
		if jobAction == nil {
			return new(int64(http.StatusBadRequest)),
				fmt.Errorf("action %s not found in task %s", req.Action, req.Task)
		}

		// append both Command and Args
		req.Cmd = append([]string{jobAction.Command}, jobAction.Args...)
	}

	if len(req.Cmd) == 0 {
		return new(int64(400)), errors.New("command is not present")
	}

	capabilities, err := ar.GetTaskDriverCapabilities(req.Task)
	if err != nil {
		code := new(int64(500))

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. List the tasks in the allocation's task group and use an exact task name
  2. Check task name spelling and case
  3. Confirm the allocation belongs to the expected job/group
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at client/alloc_endpoint.go:308 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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