hashicorp/nomad · error
Distinct Property must have an allowed count of 1 or greater
Error message
Distinct Property must have an allowed count of 1 or greater: %d < 1
What it means
A "distinct_property" constraint parsed its count successfully but the value is 0 (or otherwise below 1). Nomad requires an allowed count of at least 1, since the constraint exists to limit how many allocations may share a property value. Validation rejects the job.
Source
Thrown at nomad/structs/structs.go:10091
if _, err := regexp.Compile(c.RTarget); err != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Regular expression failed to compile: %v", err))
}
case ConstraintVersion:
if _, err := version.NewConstraint(c.RTarget); err != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Version constraint is invalid: %v", err))
}
case ConstraintSemver:
if _, err := semver.NewConstraint(c.RTarget); err != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Semver constraint is invalid: %v", err))
}
case ConstraintDistinctProperty:
// If a count is set, make sure it is convertible to a uint64
if c.RTarget != "" {
count, err := strconv.ParseUint(c.RTarget, 10, 64)
if err != nil {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Failed to convert RTarget %q to uint64: %v", c.RTarget, err))
} else if count < 1 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Distinct Property must have an allowed count of 1 or greater: %d < 1", count))
}
}
case ConstraintAttributeIsSet, ConstraintAttributeIsNotSet:
if c.RTarget != "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Operator %q does not support an RTarget", c.Operand))
}
case "=", "==", "is", "!=", "not", "<", "<=", ">", ">=":
if c.RTarget == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Operator %q requires an RTarget", c.Operand))
}
default:
mErr.Errors = append(mErr.Errors, fmt.Errorf("Unknown constraint type %q", c.Operand))
}
// If the constraint must have a "LTarget" (attribute in the job spec), then
// ensure it is not an empty string and is valid.
if requireLtarget {
if c.LTarget == "" {View on GitHub (pinned to 482b49bf1a)
Solutions
- Set the count RTarget to "1" or greater.
- If you do not want the constraint, remove the distinct_property block entirely instead of setting count 0.
- Fix the template/variable that produced 0 and re-submit.
Example fix
// before
constraint {
attribute = "${attr.unique_id}"
distinct_property = "0"
}
// after
constraint {
attribute = "${attr.unique_id}"
distinct_property = "1"
} Defensive patterns
Strategy: validation
Validate before calling
func validDistinctPropertyCount(target string) bool {
if target == "" { return true }
n, err := strconv.ParseUint(target, 10, 64)
return err == nil && n >= 1
} Try / catch
count, err := strconv.ParseUint(target, 10, 64)
if err != nil || count < 1 {
return fmt.Errorf("distinct_property count must be >= 1, got %q", target)
} Prevention
- Remove the constraint block instead of setting count 0 to disable it.
- Guard template variables that feed the count against zero defaults.
- Validate rendered jobs in CI with nomad job validate.
When it happens
Trigger: Submitting a job with distinct_property RTarget "0" (or "00", "0x0"-equivalent decimal 0), which parses to uint64 0 and fails the count < 1 check.
Common situations: Templated job generation where a loop variable defaulted to 0; intending to 'disable' the constraint by setting count 0 instead of removing it; copying config with count "0" left from a disabled example.
Related errors
- Version constraint is invalid: %v
- Semver constraint is invalid: %v
- Failed to convert RTarget %q to uint64: %v
- Operator %q does not support an RTarget
- Operator %q requires an RTarget
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/b6f1e4e8d3f71957.
Report an issue: GitHub.