{"record":{"id":"5f9efdf936b3b052","repo":"hashicorp/nomad","slug":"job-q-version-d-not-found","errorCode":null,"errorMessage":"job %q version %d not found","messagePattern":"job %q version (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":4943,"sourceCode":"\tversions, err := s.JobVersionsByID(nil, namespace, jobID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar job *structs.Job\n\n\tfor _, version := range versions {\n\t\t// Allow for a tag to be updated (new description, for example) but otherwise don't allow a same-tagname to a different version.\n\t\tif version.VersionTag != nil && version.VersionTag.Name == tag.Name && version.Version != jobVersion {\n\t\t\treturn fmt.Errorf(\"tag %q already exists on a different version of job %q\", tag.Name, jobID)\n\t\t}\n\t\tif version.Version == jobVersion {\n\t\t\tjob = version\n\t\t}\n\t}\n\n\tif job == nil {\n\t\treturn fmt.Errorf(\"job %q version %d not found\", jobID, jobVersion)\n\t}\n\n\tversionCopy := job.Copy()\n\tversionCopy.VersionTag = tag\n\tversionCopy.ModifyIndex = index\n\n\tlatestJob, err := s.JobByID(nil, namespace, jobID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif versionCopy.Version == latestJob.Version {\n\t\tif err := txn.Insert(\"jobs\", versionCopy); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn s.upsertJobVersion(index, versionCopy, txn)\n}","sourceCodeStart":4925,"sourceCodeEnd":4961,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L4925-L4961","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nPUT /v1/job/web/versions/7/tag {\"Name\":\"v1\"}   // version 7 never existed\n// after\n// GET /v1/job/web/versions -> versions [0,1,2]\nPUT /v1/job/web/versions/2/tag {\"Name\":\"v1\"}","handlingStrategy":"validation","validationCode":"versions, _, err := client.Jobs().Versions(jobID, false, nil)\nif err != nil { return err }\nexists := false\nfor _, v := range versions {\n  if v.Version == targetVersion { exists = true }\n}\nif !exists { return fmt.Errorf(\"version %d not available\", targetVersion) }","typeGuard":null,"tryCatchPattern":"err := applyTag(jobID, version, tag)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n  // refresh version list and pick a valid version\n}","preventionTips":["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"],"tags":["nomad","state-store","job-versions","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}