hashicorp/nomad · error
job %q version %d not found
Error message
job %q version %d not found
What it means
The state store could not locate the requested historical version of the job when applying a version tag. Job versions are retained per job, and tagging requires the exact version to exist in the store; the request is rejected rather than silently ignored.
Source
Thrown at nomad/state/state_store.go:4943
versions, err := s.JobVersionsByID(nil, namespace, jobID)
if err != nil {
return err
}
var job *structs.Job
for _, version := range versions {
// Allow for a tag to be updated (new description, for example) but otherwise don't allow a same-tagname to a different version.
if version.VersionTag != nil && version.VersionTag.Name == tag.Name && version.Version != jobVersion {
return fmt.Errorf("tag %q already exists on a different version of job %q", tag.Name, jobID)
}
if version.Version == jobVersion {
job = version
}
}
if job == nil {
return fmt.Errorf("job %q version %d not found", jobID, jobVersion)
}
versionCopy := job.Copy()
versionCopy.VersionTag = tag
versionCopy.ModifyIndex = index
latestJob, err := s.JobByID(nil, namespace, jobID)
if err != nil {
return err
}
if versionCopy.Version == latestJob.Version {
if err := txn.Insert("jobs", versionCopy); err != nil {
return err
}
}
return s.upsertJobVersion(index, versionCopy, txn)
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Fetch the version list (GET /v1/job/:jobId/versions) and use an existing Version number
- Re-submit the job to create a new version if the desired version is gone
- Fix automation to derive the version from the API instead of hardcoding
Example fix
// before
PUT /v1/job/web/versions/7/tag {"Name":"v1"} // version 7 never existed
// after
// GET /v1/job/web/versions -> versions [0,1,2]
PUT /v1/job/web/versions/2/tag {"Name":"v1"} Defensive patterns
Strategy: validation
Validate before calling
versions, _, err := client.Jobs().Versions(jobID, false, nil)
if err != nil { return err }
exists := false
for _, v := range versions {
if v.Version == targetVersion { exists = true }
}
if !exists { return fmt.Errorf("version %d not available", targetVersion) } Try / catch
err := applyTag(jobID, version, tag)
if err != nil && strings.Contains(err.Error(), "not found") {
// refresh version list and pick a valid version
} Prevention
- Derive version numbers from the job versions API, never hardcode
- Account for version history retention when tagging old versions
- Tag the current version (LatestDeployment) when unsure
When it happens
Trigger: JobApplyTag (PUT /v1/job/:jobId/versions/:version/tag) with a version number that was never registered or has aged out of the retained version history.
Common situations: Stale automation referencing an old version after the job was re-registered/purged; off-by-one in scripts computing the 'previous' version; jobs whose version history was trimmed.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/5f9efdf936b3b052.
Report an issue: GitHub.