hashicorp/nomad · error
error querying job %q: %w
Error message
error querying job %q: %w
What it means
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.
Source
Thrown at command/alloc_fs.go:383
r, err := streamFrames(frames, errCh, numLines, cancel)
if err != nil {
return nil, err
}
return r, nil
}
// Get Random Allocation from a known jobID. Prefer to use a running allocation,
// but use a dead allocation if no running allocations are found
func getRandomJobAlloc(client *api.Client, jobID, taskGroupName, namespace string) (*api.AllocationListStub, error) {
var runningAllocs []*api.AllocationListStub
q := &api.QueryOptions{
Namespace: namespace,
}
allocs, _, err := client.Jobs().Allocations(jobID, false, q)
if err != nil {
return nil, fmt.Errorf("error querying job %q: %w", jobID, err)
}
// Check that the job actually has allocations
if len(allocs) == 0 {
return nil, fmt.Errorf("job %q doesn't exist or it has no allocations", jobID)
}
if taskGroupName != "" {
var filteredAllocs []*api.AllocationListStub
for _, alloc := range allocs {
if alloc.TaskGroup == taskGroupName {
filteredAllocs = append(filteredAllocs, alloc)
}
}
allocs = filteredAllocs
if len(allocs) == 0 {
return nil, fmt.Errorf("task group %q doesn't exist or it has no allocations", taskGroupName)
}View on GitHub (pinned to 482b49bf1a)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at command/alloc_fs.go:383 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/136bca46015b5f50.
Report an issue: GitHub.