{"record":{"id":"b790e07bdb2bb129","repo":"hashicorp/nomad","slug":"error-looking-up-job-version-by-tag-v","errorCode":null,"errorMessage":"error looking up job version by tag: %v","messagePattern":"error looking up job version by tag: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":1281,"sourceCode":"\t\t\tout, err := state.JobVersionsByID(ws, args.RequestNamespace(), args.JobID)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Setup the output\n\t\t\treply.Versions = out\n\t\t\tif len(out) != 0 {\n\n\t\t\t\tvar compareVersionNumber uint64\n\t\t\t\tvar compareVersion *structs.Job\n\t\t\t\tvar compareSpecificVersion bool\n\n\t\t\t\tif args.Diffs {\n\t\t\t\t\tif args.DiffTagName != \"\" {\n\t\t\t\t\t\tcompareSpecificVersion = true\n\t\t\t\t\t\tcompareVersion, err = state.JobVersionByTagName(ws, args.RequestNamespace(), args.JobID, args.DiffTagName)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error looking up job version by tag: %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif compareVersion == nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"tag %q not found\", args.DiffTagName)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcompareVersionNumber = compareVersion.Version\n\t\t\t\t\t} else if args.DiffVersion != nil {\n\t\t\t\t\t\tcompareSpecificVersion = true\n\t\t\t\t\t\tcompareVersionNumber = *args.DiffVersion\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Note: a previous assumption here was that the 0th job was the latest, and that we don't modify \"old\" versions.\n\t\t\t\t// Adding version tags breaks this assumption (you can tag an old version, which should unblock /versions queries) so we now look for the highest ModifyIndex.\n\t\t\t\tvar maxModifyIndex uint64\n\t\t\t\tfor _, job := range out {\n\t\t\t\t\tif job.ModifyIndex > maxModifyIndex {\n\t\t\t\t\t\tmaxModifyIndex = job.ModifyIndex\n\t\t\t\t\t}","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L1263-L1299","documentation":"The Job.Versions (job versions diff) endpoint supports diffing against a tagged version: when args.DiffTagName is set, it calls state.JobVersionByTagName to resolve the tag to a version. This error wraps any internal state-store error from that lookup (distinct from a nil result, which yields 'tag not found').","triggerScenarios":"GET /v1/job/<id>/versions?diff=true&tag=<name> where the state store returns a non-nil error from the tag index lookup — e.g. store corruption, an internal index failure, or an unhandled query error, not simply a missing tag.","commonSituations":"Operators using 'nomad job inspect' style diff tooling with the tag parameter against a state store under stress or after a failed restore; clients passing malformed tag values that trip an unexpected store error.","solutions":["Read the wrapped %v cause to identify the underlying state-store failure","Retry the request; transient snapshot issues can resolve on a second attempt","Drop the tag parameter and diff by version number (diff_version) instead","Check server logs for state-store/raft errors; restore or repair the state store if corruption is indicated"],"exampleFix":"// before\nclient.Jobs().Versions(\"web\", true, &api.QueryOptions{Params: map[string]string{\"tag\": deploymentTag}})\n// after\nv, _, err := client.Jobs().Versions(\"web\", true, nil) // diff by latest instead of by tag\nif err != nil { return err }","handlingStrategy":"fallback","validationCode":"// no client-side pre-check exists for tag-index state errors; detect and fall back\ntag := q.Get(\"tag\")\nif tag != \"\" && !validTagPattern.MatchString(tag) { tag = \"\" }","typeGuard":null,"tryCatchPattern":"versions, _, err := client.Jobs().Versions(jobID, true, qo)\nif err != nil && strings.Contains(err.Error(), \"error looking up job version by tag\") {\n\tversions, _, err = client.Jobs().Versions(jobID, true, nil) // retry without tag\n}","preventionTips":["Prefer diffing by explicit version number over tags when possible","Check server logs alongside the wrapped error cause","Verify state-store health after restores or raft issues"],"tags":["nomad","state-store","job-versioning","internal-error"],"backgroundTag":"state-store-lookup-failed","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"}