hashicorp/nomad · error

Error fetching job: %v

Error message

Error fetching job: %v

What it means

fetchMultiRegionDeployments first fetches the job (needed to enumerate its multiregion regions) via c.Jobs().Info. If that API call fails, the error is wrapped as "Error fetching job: %v". The job lookup is a prerequisite for the per-region deployment queries.

Source

Thrown at command/deployment_status.go:604

		return base
	}
	base += "\n\n[bold]Deployed[reset]\n"
	base += formatDeploymentGroups(d.TaskGroups, uuidLength)
	return base
}

type regionResult struct {
	region string
	d      *api.Deployment
	err    error
}

func fetchMultiRegionDeployments(c *api.Client, d *api.Deployment) (map[string]*api.Deployment, error) {
	results := make(map[string]*api.Deployment)

	job, _, err := c.Jobs().Info(d.JobID, &api.QueryOptions{})
	if err != nil {
		return nil, fmt.Errorf("Error fetching job: %v", err)
	}

	requests := make(chan regionResult, len(job.Multiregion.Regions))
	for i := 0; i < cap(requests); i++ {
		go func(itr int) {
			region := job.Multiregion.Regions[itr]
			d, err := fetchRegionDeployment(c, d, region)
			requests <- regionResult{d: d, err: err, region: region.Name}
		}(i)
	}
	for i := 0; i < cap(requests); i++ {
		res := <-requests
		if res.err != nil {
			key := fmt.Sprintf("%s (error)", res.region)
			results[key] = &api.Deployment{}
			continue
		}
		results[res.region] = res.d

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the wrapped cause: if 404, the job is gone — use `nomad job list` to confirm
  2. Verify connectivity (NOMAD_ADDR) and that the agent is healthy
  3. Ensure the ACL token has `job:read` (or `read-job`) capability in the relevant namespace/region

Example fix

// before (shell)
nomad deployment status <id>  # fails: Error fetching job: job not found
// after
nomad job status <job-id>     # confirm job exists first; re-run with correct region/namespace
Defensive patterns

Strategy: retry

Validate before calling

job, _, err := c.Jobs().Info(jobID, &api.QueryOptions{Region: region})
if err != nil { return fmt.Errorf("job %s unreadable before deployment lookup: %w", jobID, err) }

Try / catch

if err := fetchMultiRegionDeployments(c, d); err != nil {
    if strings.Contains(err.Error(), "job not found") {
        // skip: job GC'd; fall back to deployment-only output
    } else {
        // transient network/ACL error: retry with backoff
    }
}

Prevention

When it happens

Trigger: formatDeployment → fetchMultiRegionDeployments on a multiregion deployment when the Jobs().Info API call errors: job deleted/GC'd, connection refused, ACL token lacking job read permission, or wrong region in QueryOptions.

Common situations: The parent job was purged while its deployment record still exists; network/ACL issues against the Nomad agent; job exists only in a different region than queried.

Related errors


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