hashicorp/nomad · error
failures_before_warning must be non-negative
Error message
failures_before_warning must be non-negative
What it means
validateConsul found a negative failures_before_warning value on a Consul check; warning/critical threshold counters must be non-negative integers.
Source
Thrown at nomad/structs/services.go:454
// and Nomad when using the pass/fail check threshold features.
//
// Consul only.
passFailCheckTypes := []string{"tcp", "http", "grpc"}
if sc.SuccessBeforePassing < 0 {
return fmt.Errorf("success_before_passing must be non-negative")
} else if sc.SuccessBeforePassing > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {
return fmt.Errorf("success_before_passing not supported for check of type %q", sc.Type)
}
if sc.FailuresBeforeCritical < 0 {
return fmt.Errorf("failures_before_critical must be non-negative")
} else if sc.FailuresBeforeCritical > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {
return fmt.Errorf("failures_before_critical not supported for check of type %q", sc.Type)
}
if sc.FailuresBeforeWarning < 0 {
return fmt.Errorf("failures_before_warning must be non-negative")
} else if sc.FailuresBeforeWarning > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {
return fmt.Errorf("failures_before_warning not supported for check of type %q", sc.Type)
}
// Arbitrary value, we could bump it if needed
if len(sc.Notes) > 255 {
return fmt.Errorf("notes must not be longer than 255 characters")
}
return nil
}
// RequiresPort returns whether the service check requires the task has a port.
func (sc *ServiceCheck) RequiresPort() bool {
switch sc.Type {
case ServiceCheckGRPC, ServiceCheckHTTP, ServiceCheckTCP:
return true
default:View on GitHub (pinned to 482b49bf1a)
Solutions
- Set failures_before_warning to 0 or a positive integer
Example fix
// before
check {
failures_before_warning = -2
}
// after
check {
failures_before_warning = 2
} Defensive patterns
Strategy: validation
Validate before calling
if sc.FailuresBeforeWarning < 0 {
return fmt.Errorf("failures_before_warning must be non-negative")
} Type guard
func validFailuresBeforeWarning(sc *ServiceCheck) bool { return sc.FailuresBeforeWarning >= 0 } Prevention
- Use 0 to disable warning tolerance
- Validate variables feeding check thresholds
When it happens
Trigger: Setting check.FailuresBeforeWarning to a negative integer in a Consul service check and validating it.
Common situations: Negative default from variable interpolation; mistyped value; copy-paste introducing a leading minus sign.
Related errors
- expose may only be set for Consul service checks
- on_update may only be set to ignore_warnings for Consul serv
- success_before_passing may only be set for Consul service ch
- failures_before_critical may only be set for Consul service
- failures_before_warning may only be set for Consul service c
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/fdddabaf7be08af5.
Report an issue: GitHub.