hashicorp/nomad · error

JobID required for actions

Error message

JobID required for actions

What it means

Job.GetActions was called with an empty JobID. The endpoint validates arguments after ACL checks and requires a job ID to scope the actions query, rejecting the request with 'JobID required for actions'.

Source

Thrown at nomad/job_endpoint.go:1727

	if done, err := j.srv.forward(structs.JobGetActionsRPCMethod, args, args, reply); done {
		return err
	}
	j.srv.MeasureRPCRate("job", structs.RateMetricRead, args)
	if authErr != nil {
		return structs.ErrPermissionDenied
	}
	defer metrics.MeasureSince([]string{"nomad", "job", "get_actions"}, time.Now())

	// Check for read-job permissions
	if aclObj, err := j.srv.ResolveACL(args); err != nil {
		return err
	} else if !aclObj.AllowNsOp(args.RequestNamespace(), acl.NamespaceCapabilityReadJob) {
		return structs.ErrPermissionDenied
	}

	// Validate the arguments
	if args.JobID == "" {
		return fmt.Errorf("JobID required for actions")
	}

	// Grab the job
	job, err := j.srv.fsm.State().JobByID(nil, args.RequestNamespace(), args.JobID)
	if err != nil {
		return err
	}
	if job == nil {
		return structs.NewErrUnknownJob(args.JobID)
	}

	// Get its task groups' tasks' actions
	jobActions := make([]*structs.JobAction, 0)
	for _, tg := range job.TaskGroups {
		for _, task := range tg.Tasks {
			for _, action := range task.Actions {
				jobAction := &structs.JobAction{
					Action:        *action,

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Populate JobID (the request's job field) before calling GetActions.
  2. Ensure the UI/route always carries the job name/id as a path parameter.
  3. Validate non-empty JobID client-side to fail early with a clear message.
  4. Confirm you intended a job-scoped call, not a namespace-wide listing endpoint.

Example fix

// before
actions, _, err := client.Jobs().GetActions("", nil)
// after
if jobID == "" { return errors.New("GetActions needs a job ID") }
actions, _, err := client.Jobs().GetActions(jobID, nil)
Defensive patterns

Strategy: validation

Validate before calling

if jobID == "" {
    return fmt.Errorf("GetActions requires a job ID")
}
actions, _, err := client.Jobs().GetActions(jobID, nil)

Type guard

func hasJobID(id string) bool { return id != "" }

Prevention

When it happens

Trigger: GET /v1/job//actions or an ActionsRequest with args.JobID == "" (caller has ReadJob ACL but supplies no ID), at nomad/job_endpoint.go:1727.

Common situations: Dashboard/UI code navigating to an actions endpoint without a selected job; API wrappers omitting the path parameter; CI scripts with an unset job-name variable.

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


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