{"record":{"id":"f856e4d0a41acfc8","repo":"hashicorp/nomad","slug":"job-q-doesn-t-exist-or-it-has-no-allocations","errorCode":null,"errorMessage":"job %q doesn't exist or it has no allocations","messagePattern":"job %q doesn't exist or it has no allocations","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/alloc_fs.go","lineNumber":388,"sourceCode":"\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}\n\t}\n\n\tfor _, v := range allocs {\n\t\tif v.ClientStatus == \"running\" {\n\t\t\trunningAllocs = append(runningAllocs, v)","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/alloc_fs.go#L370-L406","documentation":"Validation outcome in getRandomJobAlloc: the API returned the job's allocation list successfully but it is empty, meaning the job exists yet has no allocations (never scheduled, or all stopped); the command cannot pick an allocation.","triggerScenarios":"Thrown at command/alloc_fs.go:388 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run nomad job status <job> to see why the job has no allocations","Start the job or wait for scheduling to place at least one allocation","Specify a different job that currently has allocations"],"exampleFix":null,"handlingStrategy":"validation","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"}