{"record":{"id":"501b7cf39962dcd3","repo":"hashicorp/nomad","slug":"error-querying-job-allocations-s","errorCode":null,"errorMessage":"Error querying job allocations: %s","messagePattern":"Error querying job allocations: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/job_status.go","lineNumber":435,"sourceCode":"\t}\n\n\tc.Ui.Output(c.Colorize().Color(\"\\n[bold]Dispatched Jobs[reset]\"))\n\tc.Ui.Output(formatList(out))\n\treturn nil\n}\n\n// outputJobInfo prints information about the passed non-periodic job. If a\n// request fails, an error is returned.\nfunc (c *JobStatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {\n\tvar q *api.QueryOptions\n\tif job.Namespace != nil {\n\t\tq = &api.QueryOptions{Namespace: *job.Namespace}\n\t}\n\n\t// Query the allocations\n\tjobAllocs, _, err := client.Jobs().Allocations(*job.ID, c.allAllocs, q)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying job allocations: %s\", err)\n\t}\n\n\t// Query the evaluations\n\tjobEvals, _, err := client.Jobs().Evaluations(*job.ID, q)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying job evaluations: %s\", err)\n\t}\n\n\tlatestDeployment, _, err := client.Jobs().LatestDeployment(*job.ID, q)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying latest job deployment: %s\", err)\n\t}\n\n\tjobActions := make([]map[string]string, 0)\n\tfor _, tg := range job.TaskGroups {\n\t\tfor _, task := range tg.Tasks {\n\t\t\tfor _, action := range task.Actions {\n\t\t\t\tjobActions = append(jobActions, map[string]string{","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/job_status.go#L417-L453","documentation":"Raised by outputJobInfo in `nomad job status` when Jobs().Allocations(jobID, all, q) fails to fetch the job's allocation list. The client error (network, ACL, namespace, server) is wrapped into this message and shown instead of the allocation table. Note the query also fails when the job ID doesn't resolve in the selected namespace.","triggerScenarios":"client.Jobs().Allocations(*job.ID, c.allAllocs, q) returns an error: agent unreachable, ACL token missing allocation-list permission in the namespace, wrong -namespace/-region, or server 5xx during the read.","commonSituations":"Token restricted to other namespaces; listing allocations for a job in the default namespace when it exists elsewhere; network interruption or agent restart while running status; stale NOMAD_ADDR after cluster migration.","solutions":["Fix the underlying cause shown after the colon (connection refused/DNS, permission denied, 5xx).","Set the correct namespace/region: nomad job status -namespace <ns> -region <r> <job>.","Validate ACLs: the token needs list-jobs and read-alloc permissions in the target namespace.","Retry after transient server errors (leader election) or restore agent connectivity."],"exampleFix":"// before\ncurl -s $NOMAD_ADDR/v1/job/web/allocations   # 403 permission denied\n// after\nexport NOMAD_TOKEN=<token-with-alloc-read>\nnomad job status -namespace default web","handlingStrategy":"try-catch","validationCode":"# pre-flight: can this token list allocations in the namespace?\ncurl -sf -H \"X-Nomad-Token: $NOMAD_TOKEN\" \\\n  \"$NOMAD_ADDR/v1/job/$JOB_ID/allocations?namespace=$NOMAD_NAMESPACE\" > /dev/null","typeGuard":"func isPermDenied(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"permission denied\")\n}","tryCatchPattern":"jobAllocs, _, err := client.Jobs().Allocations(id, all, q)\nif err != nil {\n    switch {\n    case isPermDenied(err):\n        return fmt.Errorf(\"token lacks allocation read in %s\", ns)\n    default:\n        return retryWithBackoff(...)\n    }\n}","preventionTips":["Verify namespace/region flags before running status in multi-namespace clusters.","Grant read-alloc capability to automation tokens.","Check connectivity (nomad server members) before bulk status commands.","Keep CLI and agent versions compatible after upgrades."],"tags":["nomad","cli","api-client","allocations"],"backgroundTag":"job-query-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"}