{"record":{"id":"4526a03a6ae17ed5","repo":"hashicorp/nomad","slug":"success-before-passing-not-supported-for-check-of","errorCode":null,"errorMessage":"success_before_passing not supported for check of type %q","messagePattern":"success_before_passing not supported for check of type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":444,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"notes must not be longer than 255 characters\")\n\t}","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L426-L462","documentation":"Nomad's Consul service check validation rejects setting success_before_passing on check types that do not support pass/fail semantics. Only tcp, http, and grpc checks may use it. The error names the offending check type.","triggerScenarios":"Setting ServiceRegistration or Service check field SuccessBeforePassing > 0 on a check whose Type is not tcp/http/grpc (e.g. script, ttl checks), then calling Validate on the service.","commonSituations":"Copying success_before_passing from an HTTP check block into a 'script' or 'ttl' check; typos in check type; templates generating checks with a default empty/unsupported type.","solutions":["Remove success_before_passing from checks whose type is not tcp/http/grpc","Change the check type to tcp, http, or grpc if pass/fail gating is desired","Set success_before_passing to 0 to disable the feature"],"exampleFix":"// before\ncheck {\n  type = \"script\"\n  success_before_passing = 3\n}\n// after\ncheck {\n  type = \"http\"\n  success_before_passing = 3\n}","handlingStrategy":"validation","validationCode":"var passFail = []string{\"tcp\",\"http\",\"grpc\"}\nif sc.SuccessBeforePassing > 0 && !slices.Contains(passFail, sc.Type) {\n    return fmt.Errorf(\"success_before_passing unsupported for type %q\", sc.Type)\n}","typeGuard":"func supportsPassFail(sc *ServiceCheck) bool {\n    return slices.Contains([]string{\"tcp\",\"http\",\"grpc\"}, sc.Type)\n}","tryCatchPattern":null,"preventionTips":["Only set success_before_passing on tcp/http/grpc checks","Validate job with nomad job validate before submission","Keep shared check templates split per check type"],"tags":["nomad","consul","service-check","validation"],"backgroundTag":"invalid-check-configuration","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"}