{"record":{"id":"bd5771bf9eae670f","repo":"hashicorp/nomad","slug":"job-submission-lookup-failed-v","errorCode":null,"errorMessage":"job submission lookup failed: %v","messagePattern":"job submission lookup failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":2317,"sourceCode":"\t}\n\tws.Add(iter.WatchCh())\n\n\treturn iter, nil\n}\n\n// JobSubmission returns the original HCL/Variables context of a job, if available.\n//\n// Note: it is a normal case for the submission context to be unavailable, in which case\n// nil is returned with no error.\nfunc (s *StateStore) JobSubmission(ws memdb.WatchSet, namespace, jobName string, version uint64) (*structs.JobSubmission, error) {\n\ttxn := s.db.ReadTxn()\n\treturn s.jobSubmission(ws, namespace, jobName, version, txn)\n}\n\nfunc (s *StateStore) jobSubmission(ws memdb.WatchSet, namespace, jobName string, version uint64, txn Txn) (*structs.JobSubmission, error) {\n\twatchCh, existing, err := txn.FirstWatch(\"job_submission\", \"id\", namespace, jobName, version)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"job submission lookup failed: %v\", err)\n\t}\n\tws.Add(watchCh)\n\tif existing != nil {\n\t\treturn existing.(*structs.JobSubmission), nil\n\t}\n\treturn nil, nil\n}\n\n// JobByID is used to lookup a job by its ID. JobByID returns the current/latest job\n// version.\nfunc (s *StateStore) JobByID(ws memdb.WatchSet, namespace, id string) (*structs.Job, error) {\n\ttxn := s.db.ReadTxn()\n\treturn s.JobByIDTxn(ws, namespace, id, txn)\n}\n\n// JobByIDTxn is used to lookup a job by its ID, like  JobByID. JobByID returns the job version\n// accessible through in the transaction\nfunc (s *StateStore) JobByIDTxn(ws memdb.WatchSet, namespace, id string, txn Txn) (*structs.Job, error) {","sourceCodeStart":2299,"sourceCodeEnd":2335,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L2299-L2335","documentation":"This helper fetches a single JobSubmission by namespace, job name, and version using txn.FirstWatch. The error wraps a lookup failure on the job_submission table; it indicates the query errored (not merely that no submission exists, which returns nil,nil).","triggerScenarios":"Calling JobSubmission (or JobSubmissionTxn) with a namespace/name/version where the internal FirstWatch query on job_submission 'id' index fails.","commonSituations":"Rare; seen in job read RPC paths when the underlying memdb query errors, e.g. during internal index issues.","solutions":["Read the wrapped %v cause to find the underlying error","Retry the read; typically transient","If persistent, check state store health and report upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isSubmissionLookupErr(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"job submission lookup failed\")\n}","tryCatchPattern":"sub, _, err := client.Jobs().Submission(jobID, ns, version)\nif err != nil {\n  if isSubmissionLookupErr(err) { /* query failure, retry */ } else { /* other */ }\n}\n// note: nil sub is not an error — submission may not exist","preventionTips":["Treat nil result as missing, not failure","Retry on query errors","Check job version exists before querying its submission"],"tags":["nomad","state-store","job-submission"],"backgroundTag":"state-store-read-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"}