hashicorp/nomad · error

Could not find job version %d for region

Error message

Could not find job version %d for region

What it means

After successfully listing deployments for the job in a region, fetchRegionDeployment scans for one whose JobVersion equals the original deployment's version. If none matches, it returns "Could not find job version %d for region", meaning that region never deployed (or no longer records) this job version.

Source

Thrown at command/deployment_status.go:643

	return results, nil
}

func fetchRegionDeployment(c *api.Client, d *api.Deployment, region *api.MultiregionRegion) (*api.Deployment, error) {
	if region == nil {
		return nil, errors.New("Region not found")
	}

	opts := &api.QueryOptions{Region: region.Name}
	deploys, _, err := c.Jobs().Deployments(d.JobID, false, opts)
	if err != nil {
		return nil, fmt.Errorf("Error fetching deployments for job %s: %v", d.JobID, err)
	}
	for _, dep := range deploys {
		if dep.JobVersion == d.JobVersion {
			return dep, nil
		}
	}
	return nil, fmt.Errorf("Could not find job version %d for region", d.JobVersion)
}

func formatMultiregionDeployment(regions map[string]*api.Deployment, uuidLength int) string {
	rowString := "Region|ID|Status"
	rows := make([]string, len(regions)+1)
	rows[0] = rowString
	i := 1
	for k, v := range regions {
		row := fmt.Sprintf("%s|%s|%s", k, limit(v.ID, uuidLength), v.Status)
		rows[i] = row
		i++
	}
	sort.Strings(rows)
	return formatList(rows)
}

func formatDeploymentGroups(tgs map[string]*api.DeploymentState, uuidLength int) string {
	// Detect if we need to add these columns

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run `nomad job deployments -json <job>` per region to see which versions each region recorded
  2. Check the failing region's deployment history; if GC removed it, use the full deployment list instead of the status command
  3. Trigger a new deployment (`nomad job run`) if the region needs to catch up to the current version

Example fix

// before
nomad deployment status <multiregion-deploy-id>  # Could not find job version 4 for region
// after
nomad job deployments -region=<region> <job-id>  # inspect recorded versions per region
Defensive patterns

Strategy: fallback

Validate before calling

deps, _, err := c.Jobs().Deployments(jobID, false, &api.QueryOptions{Region: region})
// check any dep.JobVersion == wantedVersion before relying on it
hasVersion := false
for _, d := range deps { if d.JobVersion == wantedVersion { hasVersion = true } }

Try / catch

dep, err := fetchRegionDeployment(c, region, d)
if err != nil {
    // fall back to listing all regional deployments for the job
    return formatJobDeploymentsFallback(c, d.JobID, region.Name)
}

Prevention

When it happens

Trigger: fetchRegionDeployment (invoked from the per-region goroutine) finds the region's deployment list contains no entry with dep.JobVersion == d.JobVersion — e.g. the region's deployment for that version was GC'd or the region failed before its deployment was created.

Common situations: Multiregion jobs where one region failed early and never registered a deployment; old deployment records for that version were garbage-collected; job was updated so versions diverged between regions.

Related errors


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