hashicorp/nomad · error
Error querying job %q: %s
Error message
Error querying job %q: %s
What it means
Returned by JobByPrefix in command/meta.go when client.Jobs().Info(jobID, q) fails after a prefix lookup resolved a candidate job ID. It wraps the API error and names the resolved job ID. Because the ID came from PrefixList, a 404 here usually means the job vanished between the list and info calls or the namespace differs.
Source
Thrown at command/meta.go:335
}
func (e *NoJobWithPrefixError) Error() string {
return fmt.Sprintf("No job(s) with prefix or ID %q found", e.Prefix)
}
// JobByPrefix returns the job that best matches the given prefix. Returns an
// error if there are no matches or if there are more than one exact match
// across namespaces.
func (m *Meta) JobByPrefix(client *api.Client, prefix string) (*api.Job, error) {
jobID, namespace, err := m.JobIDByPrefix(client, prefix)
if err != nil {
return nil, err
}
q := &api.QueryOptions{Namespace: namespace}
job, _, err := client.Jobs().Info(jobID, q)
if err != nil {
return nil, fmt.Errorf("Error querying job %q: %s", jobID, err)
}
job.Namespace = new(namespace)
return job, nil
}
// JobByPrefixFilterFunc filters jobs during a client-side prefix match. It is
// the fallback for servers that cannot evaluate the server-side filter expression.
type JobByPrefixFilterFunc func(*api.JobListStub) bool
// JobIDByPrefix provides best effort match for the given job prefix.
// Returns the prefix itself if job prefix search is not allowed and an error
// if there are no matches or if there are more than one exact match across
// namespaces.
func (m *Meta) JobIDByPrefix(client *api.Client, prefix string) (string, string, error) {
return m.jobIDByPrefix(client, prefix, "", nil)
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Check the wrapped cause: 404 = wrong ID/deleted job, 403 = permissions, transport = connectivity.
- Run `nomad job status` with no args (or `nomad status`) to list jobs and confirm the exact ID.
- Pass -namespace or set NOMAD_NAMESPACE to match where the job actually lives.
- Inspect the ACL token (`nomad acl token info`) and ensure it has read-job in the target namespace.
- Retry if the cause is transient (the job may have been mid-purge).
Example fix
// before: job is in another namespace nomad job status webapp // after nomad job status -namespace prod webapp
Defensive patterns
Strategy: try-catch
Validate before calling
// resolve and confirm the exact ID first nomad job status -namespace "$NS" "$EXACT_JOB_ID" >/dev/null 2>&1 || echo "job $EXACT_JOB_ID not found in $NS"
Try / catch
job, err := JobByPrefix(client, ns, prefix)
if err != nil && strings.Contains(err.Error(), "Error querying job") {
var notFound bool
if strings.Contains(err.Error(), "404") || strings.Contains(err.Error(), "not found") { notFound = true }
// handle notFound distinctly from auth/network errors
} Prevention
- Always pass the full exact job ID in scripts instead of prefixes.
- Match the token's namespaces with the job's namespace.
- Confirm jobs exist before inspecting in CI pipelines.
- Keep NOMAD_NAMESPACE consistent across commands.
When it happens
Trigger: Any command that resolves a job by ID/prefix (e.g. `nomad job status web`) where Jobs().Info errors: exact ID does not exist (404), ACL token cannot read jobs in the given namespace (403), namespace flag/env targets a nonexistent namespace, or connection failure.
Common situations: Typo'd or partially-typed job names; token scoped to namespace A while job lives in namespace B; job deleted by CI right before inspection; NOMAD_NAMESPACE mismatch.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Error querying job prefix %q: %s
- no one-time token returned
- no ACL token returned
- errMissingACLRoleID
- errMissingACLAuthMethodName
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/a9d1436511c25c65.
Report an issue: GitHub.