{"record":{"id":"f5aa9aa484c7d1fe","repo":"hashicorp/nomad","slug":"error-querying-latest-job-deployment-s","errorCode":null,"errorMessage":"Error querying latest job deployment: %s","messagePattern":"Error querying latest job deployment: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/job_status.go","lineNumber":446,"sourceCode":"\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{\n\t\t\t\t\t\"group\":  *tg.Name,\n\t\t\t\t\t\"task\":   task.Name,\n\t\t\t\t\t\"action\": action.Name,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// Output the summary\n\tif err := c.outputJobSummary(client, job); err != nil {\n\t\treturn err","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/job_status.go#L428-L464","documentation":"Raised by outputJobInfo when Jobs().LatestDeployment(jobID, q) fails while fetching the most recent deployment for the status output. The API error is wrapped into this message. This is a read of deployment state, so failures typically stem from ACL restrictions, wrong namespace, connectivity loss, or older Nomad servers/agents where the deployments endpoint behaves unexpectedly.","triggerScenarios":"client.Jobs().LatestDeployment(*job.ID, q) returns an error: ACL token lacking deployment read in the namespace, namespace/region mismatch, network error to the agent, or server 5xx; also possible when talking to a much older Nomad version from a newer CLI.","commonSituations":"Restricted ACL policies on production namespaces; status run against an agent in a different region than the job; transient leader failover between sequential queries in outputJobInfo.","solutions":["Read the wrapped cause and fix it: connectivity, permissions, or server health.","Add deployment read permissions to the ACL policy for the namespace (deployment = read, or read all).","Run with the correct -namespace/-region for the job.","Upgrade/downgrade-align CLI and server versions if the cause is an endpoint/version mismatch, and retry on transient errors."],"exampleFix":"// before\nnamespace \"prod\" {\n  deployment = \"deny\"\n}\n// after\nnamespace \"prod\" {\n  deployment = \"read\"\n}","handlingStrategy":"try-catch","validationCode":"# ensure deployments are enabled/readable in this cluster+namespace\ncurl -sf -H \"X-Nomad-Token: $NOMAD_TOKEN\" \\\n  \"$NOMAD_ADDR/v1/job/$JOB_ID/deployment?namespace=$NOMAD_NAMESPACE\" > /dev/null","typeGuard":"func isACLdenied(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"Permission denied\")\n}","tryCatchPattern":"dep, _, err := client.Jobs().LatestDeployment(id, q)\nif err != nil {\n    if isACLdenied(err) {\n        // proceed without deployment info or fix policy\n    } else {\n        return err\n    }\n}","preventionTips":["Grant deployment = read in ACL policies for monitoring/status tooling.","Align Nomad CLI and server versions (deployments endpoint changes across versions).","Run status with the job's own namespace/region.","Tolerate missing/degraded deployment info in dashboards rather than failing hard."],"tags":["nomad","cli","api-client","deployment"],"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"}