{"record":{"id":"e06012528af7020d","repo":"hashicorp/nomad","slug":"error-querying-job-prefix-q-s","errorCode":null,"errorMessage":"Error querying job prefix %q: %s","messagePattern":"Error querying job prefix %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/meta.go","lineNumber":375,"sourceCode":"// to the results instead.\nfunc (m *Meta) jobIDByPrefix(client *api.Client, prefix, filter string, clientFilter JobByPrefixFilterFunc) (string, string, error) {\n\tmaxResults := 20 // reduce load for large sets\n\tjobs, _, err := client.Jobs().ListOptions(nil, &api.QueryOptions{\n\t\tPrefix:  prefix,\n\t\tFilter:  filter,\n\t\tPerPage: int32(maxResults),\n\t})\n\ttruncated := len(jobs) >= maxResults\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), api.PermissionDeniedErrorContent) {\n\t\t\treturn prefix, \"\", nil\n\t\t}\n\t\t// Servers older than 1.11.3 reject the \"is not nil\" filter operator\n\t\t// while building the result paginator. Retry without the server-side\n\t\t// filter and narrow the results on the client.\n\t\t// COMPAT(2.0): remove this fallback once 1.10LTS is out of support\n\t\tif clientFilter == nil || !strings.Contains(err.Error(), api.ResultPaginatorErrorContent) {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"Error querying job prefix %q: %s\", prefix, err)\n\t\t}\n\t\tjobs, _, err = client.Jobs().PrefixList(prefix)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"Error querying job prefix %q: %s\", prefix, err)\n\t\t}\n\t\tvar filtered []*api.JobListStub\n\t\tfor _, j := range jobs {\n\t\t\tif clientFilter(j) {\n\t\t\t\tfiltered = append(filtered, j)\n\t\t\t}\n\t\t}\n\t\tjobs = filtered\n\t\ttruncated = false // the unfiltered prefix list is complete\n\t}\n\n\tif len(jobs) == 0 {\n\t\treturn \"\", \"\", &NoJobWithPrefixError{Prefix: prefix}\n\t}","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/meta.go#L357-L393","documentation":"Returned by jobIDByPrefix when the paginated prefix-list request (Jobs().PrefixList with a server-side filter) fails and the error is not the known paginator 'is not nil' filter bug from servers older than 1.11.3. Any non-paginator failure — ACL denial, bad namespace, network error — surfaces through this wrap.","triggerScenarios":"A prefix-based job resolution (e.g. `nomad job status web`) where GET /v1/jobs?prefix=... errors, and either no client-side fallback filter was supplied or the error does not contain api.ResultPaginatorErrorContent: 403 on job listing, invalid namespace, connection refused.","commonSituations":"Older Nomad servers (<1.11.3) hitting the paginator filter bug (that path is retried separately); tokens without list-jobs capability; typo'd namespace in -namespace flag; cluster unreachable during scripted status checks.","solutions":["Read the wrapped cause to identify 403 vs 404 vs transport failure.","Upgrade the Nomad servers to >=1.11.3 if you see repeated paginator-related filter errors.","Ensure the ACL token can list jobs in the target namespace(s).","Verify the -namespace/NOMAD_NAMESPACE value exists (`nomad namespace list`).","Check connectivity to NOMAD_ADDR and retry transient failures."],"exampleFix":"// before: token can't list jobs in default namespace\nNOMAD_TOKEN=<restricted> nomad job status web\n// after\nNOMAD_TOKEN=<token-with-list-jobs> nomad job status -namespace prod web","handlingStrategy":"try-catch","validationCode":"nomad namespace list >/dev/null 2>&1 || echo \"cannot list: token or connectivity problem\"","typeGuard":null,"tryCatchPattern":"id, ns, err := JobIDByPrefix(client, ns, prefix, filter)\nif err != nil && strings.Contains(err.Error(), \"Error querying job prefix\") {\n    if !strings.Contains(err.Error(), api.ResultPaginatorErrorContent) {\n        // genuine failure: classify 403/404/transport and act\n    }\n}","preventionTips":["Upgrade Nomad servers to >=1.11.3 to avoid paginator filter failures.","Ensure tokens can list jobs in target namespaces.","Validate -namespace values against `nomad namespace list`.","Prefer exact IDs in automation over prefix resolution."],"tags":["nomad-cli","prefix-lookup","api-error","compatibility"],"backgroundTag":"nomad-api-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"}