{"record":{"id":"5c520cfc4f5c2cb1","repo":"hashicorp/nomad","slug":"success-before-passing-must-be-non-negative","errorCode":null,"errorMessage":"success_before_passing must be non-negative","messagePattern":"success_before_passing must be non-negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":442,"sourceCode":"\t// Consul only.\n\tif sc.Expose {\n\t\t// We can however immediately ensure expose is configured only for HTTP\n\t\t// and gRPC checks.\n\t\tswitch checkType {\n\t\tcase ServiceCheckGRPC, ServiceCheckHTTP: // ok\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"expose may only be set on HTTP or gRPC checks\")\n\t\t}\n\t}\n\n\t// passFailCheckTypes are intersection of check types supported by both Consul\n\t// and Nomad when using the pass/fail check threshold features.\n\t//\n\t// Consul only.\n\tpassFailCheckTypes := []string{\"tcp\", \"http\", \"grpc\"}\n\n\tif sc.SuccessBeforePassing < 0 {\n\t\treturn fmt.Errorf(\"success_before_passing must be non-negative\")\n\t} else if sc.SuccessBeforePassing > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"success_before_passing not supported for check of type %q\", sc.Type)\n\t}\n\n\tif sc.FailuresBeforeCritical < 0 {\n\t\treturn fmt.Errorf(\"failures_before_critical must be non-negative\")\n\t} else if sc.FailuresBeforeCritical > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"failures_before_critical not supported for check of type %q\", sc.Type)\n\t}\n\n\tif sc.FailuresBeforeWarning < 0 {\n\t\treturn fmt.Errorf(\"failures_before_warning must be non-negative\")\n\t} else if sc.FailuresBeforeWarning > 0 && !slices.Contains(passFailCheckTypes, sc.Type) {\n\t\treturn fmt.Errorf(\"failures_before_warning not supported for check of type %q\", sc.Type)\n\t}\n\n\t// Arbitrary value, we could bump it if needed\n\tif len(sc.Notes) > 255 {","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L424-L460","documentation":"validateConsul found a negative success_before_passing value on a Consul check; the pass/fail threshold counters must be non-negative integers.","triggerScenarios":"Thrown at nomad/structs/services.go:442 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set success_before_passing to 0 or a positive integer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}