hashicorp/nomad · error
Prefix %q matched multiple jobs\n\n%s%s
Error message
Prefix %q matched multiple jobs\n\n%s%s
What it means
Returned by jobIDByPrefix when a job prefix is ambiguous: either there is no exact ID match among the candidates, or the top two matches share the same job ID in different namespaces. The CLI refuses to guess and prints the full candidate list (plus a truncation hint if results were cut off) so the user can disambiguate.
Source
Thrown at command/meta.go:402
filtered = append(filtered, j)
}
}
jobs = filtered
truncated = false // the unfiltered prefix list is complete
}
if len(jobs) == 0 {
return "", "", &NoJobWithPrefixError{Prefix: prefix}
}
if len(jobs) > 1 {
exactMatch := prefix == jobs[0].ID
matchInMultipleNamespaces := m.allNamespaces() && jobs[0].ID == jobs[1].ID
truncatedMsg := ""
if truncated {
truncatedMsg = "\n(results may be truncated)"
}
if !exactMatch || matchInMultipleNamespaces {
return "", "", fmt.Errorf(
"Prefix %q matched multiple jobs\n\n%s%s",
prefix,
createStatusListOutput(jobs, m.allNamespaces()),
truncatedMsg,
)
}
}
return jobs[0].ID, jobs[0].JobSummary.Namespace, nil
}
type usageOptsFlags uint8
const (
usageOptsDefault usageOptsFlags = 0
usageOptsNoNamespace = 1 << iota
)
View on GitHub (pinned to 482b49bf1a)
Solutions
- Use a longer prefix so exactly one job matches, e.g. `nomad job status webap`.
- Specify the job's full ID exactly — an exact ID match bypasses the ambiguity error.
- Pass -namespace <ns> to narrow the search to one namespace.
- Read the candidate list printed in the error and pick the right ID.
- If the list was truncated, add namespace filters to reduce result size.
Example fix
// before: ambiguous nomad job status web // after: exact ID and namespace nomad job status -namespace prod webapp
Defensive patterns
Strategy: validation
Validate before calling
// resolve ambiguity before invoking: count matches yourself
matches=$(nomad job status -namespace "$NS" | grep -c "^$PREFIX")
[ "$matches" -le 1 ] || { echo "prefix '$PREFIX' is ambiguous in $NS"; exit 1; } Try / catch
id, ns, err := JobIDByPrefix(client, ns, prefix, filter)
if err != nil && strings.Contains(err.Error(), "matched multiple jobs") {
// print err (it embeds the candidate list) and prompt user to refine
return fmt.Errorf("refine prefix: %w", err)
} Prevention
- Use full job IDs in scripts, prefixes only interactively.
- Always pass -namespace in multi-namespace clusters.
- Avoid very short/generic prefixes like 'web' or 'api'.
- Keep job naming conventions distinct per namespace.
When it happens
Trigger: A prefix like `nomad job status we` that matches multiple jobs (e.g. web, webapp) with no exact match, or one job ID existing in several namespaces while -all-namespaces/-namespace wildcard is in effect, making the match ambiguous.
Common situations: Short prefixes in namespaces with similarly-named jobs; identical job names deployed in dev and prod namespaces queried with all-namespaces mode; overly generic prefixes like 'api' or 'job'.
Related errors
- Error querying job prefix %q: %s
- Error querying job %q: %s
- error getting client config: %v
- error parsing: root should be an object
- Prefix matched multiple nodes\n\n%s
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/05f41f8cf393bbec.
Report an issue: GitHub.