{"record":{"id":"136bca46015b5f50","repo":"hashicorp/nomad","slug":"error-querying-job-q-w","errorCode":null,"errorMessage":"error querying job %q: %w","messagePattern":"error querying job %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/alloc_fs.go","lineNumber":383,"sourceCode":"\tr, err := streamFrames(frames, errCh, numLines, cancel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r, nil\n}\n\n// Get Random Allocation from a known jobID. Prefer to use a running allocation,\n// but use a dead allocation if no running allocations are found\nfunc getRandomJobAlloc(client *api.Client, jobID, taskGroupName, namespace string) (*api.AllocationListStub, error) {\n\tvar runningAllocs []*api.AllocationListStub\n\tq := &api.QueryOptions{\n\t\tNamespace: namespace,\n\t}\n\n\tallocs, _, err := client.Jobs().Allocations(jobID, false, q)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error querying job %q: %w\", jobID, err)\n\t}\n\n\t// Check that the job actually has allocations\n\tif len(allocs) == 0 {\n\t\treturn nil, fmt.Errorf(\"job %q doesn't exist or it has no allocations\", jobID)\n\t}\n\n\tif taskGroupName != \"\" {\n\t\tvar filteredAllocs []*api.AllocationListStub\n\t\tfor _, alloc := range allocs {\n\t\t\tif alloc.TaskGroup == taskGroupName {\n\t\t\t\tfilteredAllocs = append(filteredAllocs, alloc)\n\t\t\t}\n\t\t}\n\t\tallocs = filteredAllocs\n\t\tif len(allocs) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"task group %q doesn't exist or it has no allocations\", taskGroupName)\n\t\t}","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/alloc_fs.go#L365-L401","documentation":"getRandomJobAlloc wraps any failure of client.Jobs().Allocations(jobID,...) - the API call to list a job's allocations - with the job ID for context; e.g. the job doesn't exist, or the region/namespace is wrong.","triggerScenarios":"Thrown at command/alloc_fs.go:383 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the job ID exists via nomad job status","Check the -namespace and region flags match where the job was submitted","Retry if the cluster was temporarily unreachable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}