{"record":{"id":"bc318a6781f2b4d1","repo":"hashicorp/nomad","slug":"error-querying-job-s","errorCode":null,"errorMessage":"Error querying job: %s","messagePattern":"Error querying job: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/job_status.go","lineNumber":350,"sourceCode":"\t\tc.Ui.Warn(hint)\n\t}\n\n\treturn 0\n}\n\n// outputPeriodicInfo prints information about the passed periodic job. If a\n// request fails, an error is returned.\nfunc (c *JobStatusCommand) outputPeriodicInfo(client *api.Client, job *api.Job) error {\n\t// Output the summary\n\tif err := c.outputJobSummary(client, job); err != nil {\n\t\treturn err\n\t}\n\n\t// Generate the prefix that matches launched jobs from the periodic job.\n\tprefix := fmt.Sprintf(\"%s%s\", *job.ID, api.JobPeriodicLaunchSuffix)\n\tchildren, _, err := client.Jobs().PrefixList(prefix)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying job: %s\", err)\n\t}\n\n\tif len(children) == 0 {\n\t\tc.Ui.Output(\"\\nNo instances of periodic job found\")\n\t\treturn nil\n\t}\n\n\tout := make([]string, 1)\n\tout[0] = \"ID|Status\"\n\tfor _, child := range children {\n\t\t// Ensure that we are only showing jobs whose parent is the requested\n\t\t// job.\n\t\tif child.ParentID != *job.ID {\n\t\t\tcontinue\n\t\t}\n\n\t\tout = append(out, fmt.Sprintf(\"%s|%s\",\n\t\t\tchild.ID,","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/job_status.go#L332-L368","documentation":"Raised by outputPeriodicInfo in `nomad job status` when the API call Jobs().PrefixList(prefix) — which lists child jobs launched by a periodic job, using the <job-id><JobPeriodicLaunchSuffix> prefix — fails. The raw client error (connection, ACL, server error) is interpolated with %s and reported as a job-query failure.","triggerScenarios":"client.Jobs().PrefixList(prefix) returns an error while listing periodic job instances: agent unreachable, ACL token lacking job read in the namespace, wrong namespace/region query options, or server-side 5xx.","commonSituations":"Running nomad job status with a read-only or expired token against a namespace-restricted cluster; NOMAD_ADDR pointing at a down agent; periodic job inspected across namespace boundary without -namespace flag.","solutions":["Check the interpolated cause: fix connectivity (curl $NOMAD_ADDR/v1/agent/health) or restart the Nomad agent.","Pass the correct -namespace/-region or set NOMAD_NAMESPACE/NOMAD_REGION so the prefix list targets the right scope.","Verify the ACL token can list jobs in the namespace (namespace = list-jobs); refresh with nomad acl token self or request a scoped token.","Retry if the server returned a transient 5xx (raft leadership change)."],"exampleFix":"// before\nnomad job status periodic-backup   // Error querying job: permission denied\n// after\nNOMAD_NAMESPACE=prod nomad acl token self     # confirm scope\nNOMAD_NAMESPACE=prod nomad job status periodic-backup","handlingStrategy":"retry","validationCode":"// confirm agent reachability and token scope first\ncurl -sf -H \"X-Nomad-Token: $NOMAD_TOKEN\" \"$NOMAD_ADDR/v1/jobs?namespace=$NOMAD_NAMESPACE\" > /dev/null","typeGuard":null,"tryCatchPattern":"children, _, err := client.Jobs().PrefixList(prefix)\nif err != nil {\n    if strings.Contains(err.Error(), \"permission denied\") {\n        // fix ACL token, do not retry\n    } else {\n        // transient: retry with backoff\n    }\n    return err\n}","preventionTips":["Export NOMAD_NAMESPACE/NOMAD_REGION (or flags) matching the job's scope in every script.","Use tokens with list-jobs capability in the target namespace.","Health-check the agent (nomad node status) before scripted status queries.","Retry idempotent reads on 5xx with exponential backoff."],"tags":["nomad","cli","api-client","job-status"],"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"}